Reputation:
I just created a working example chat programm with socket.io using express for setting up the server. Just like it is described on the socket.io webpage.
The Client Html File is sent to the client when connecting to the ip adress with a browser.
var express = require("express"),
app = express(),
server = require("http").createServer(app),
io = require("socket.io").listen(server),
mongoose = require("mongoose"),
users = {};
server.listen(3000, function(){
console.log("Server erfolgreich initialisiert!");});
app.get("/", function(req, res) {
res.sendFile(__dirname + "/index.html");});
But I want the Clients Index.html to connect to the server itself and not being send by the server side. With a HttpRequest as a handshake or anyhow. I found nothing on the socket.io webpage and no working answer in here so I doubt that it is even possible. Or is the code I have already working and I only have to change something else?
I appreciate your help!
Upvotes: 0
Views: 1106
Reputation:
I got the answer!!! I actually just failed. I just got confused by some wrong information and some Bugs. A simple
var socket = io.connect("http://199.91.38.266:3000");
already worked. (random IP of course)
of course there must be the socket.io framework included:
<script src="http://199.91.38.266:3000/socket.io/socket.io.js"></script>
Upvotes: 1