Reputation: 2187
I'm trying to connect a client side application (written in c++, although that shouldn't have any impact) to a node.js server that is written using express and socket.io.
The server pretty much boils down to:
var express = require('express');
var http = require('http')
var app = express();
var server = http.createServer(app)
var io = require('socket.io').listen(server);
app.use(express.cookieParser());
app.use(express.session({
...
}));
app.use(app.router);
// response handling -------
app.get('/', function(req, res){
console.log('request get /');
});
io.sockets.on('connection', function(socket) {
console.log('sockets.io connection!');
});
// -------
port = 3000
app.listen(port);
console.log('Listening on port: ' + port);
When I fire up this node I try two things:
So my question is: have I misunderstood either the setup or function of sockets.io? How can I connect my application to this node server?
Thanks!
Upvotes: 1
Views: 2732
Reputation: 829
Firstly, do you include the module-specific socket.io library on the client? Do you connect to the right socket / end-point?
io.connect('http://localhost');
For the native application, you can try using already implemented Socket.IO-modules for C++.
The latter one uses Boost.
If I understood something wrong, please post some debug info by dumping the internal state on a new connection-trial.
Upvotes: 1