0

I'm building an application that links to a node.js hosted on my home computer (78.233.79.103:8000)

The server is properly istalled (if you go to the addres I gave you'll se the socket.io works) If I run the server in localhost with

node server.js

all is good, the application works

Then when I run the application on my other pc or on my iPad (I wrapped it with phoneGap so it's just a web app included in a native iOS app), trying to connect the io on 78.233.79.103:8000 i got the console log:

io is not defined

here is my sourcecode: https://github.com/synbioz/puissance4

look for the server.js

I know I only call io = require('socket.io').listen(PORT); but kwnow also I should create something like:

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(8000, '78.233.79.103');

that actually doesn't works

Any idea?

4

1 回答 1

0

可能是因为 .listen() 不返回this

尝试将它们写在单独的行中。

var io = require('socket.io');
io.listen(PORT);
于 2012-05-22T17:46:21.077 回答