Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have seen the introductory course on YouTube (1 hour), and I wanted to try and "clone" the chat example on my pc.
I have installed node.js for windows (0.8.2), and I have opened the command prompt in the start menu folder called: "Node.js command prompt",
Then I created a file named: "chat.js".

chat.js:

var net = require('net');
var sockets = [];

var server = net.createServer(function (socket){
    sockets.push(socket);
    socket.write("Hello and Welcome!\n");
    socket.on('data', function(data){
        for(var i  = 0;i<sockets.length;i++){
            if(socket != sockets[i]){
                sockets[i].write(data);
            }
        }
    });
    socket.on('end', function(){
        sockets.splice (sockets.indexOf(socket),1);
        socket.end("Ended Chat");
    });
});

server.listen(8000);

When I type node chat.js I get the following: enter image description here

And it stays that way.
When I try to connect via telnet I get the following:
enter image description here

What should I do in order to start the server correctly and start communicating with it?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

The telnet command is wrong. Should be telnet 127.0.0.1 8000. Space instead of a : between hostname and port. You can see this from the error message that it's trying to connect via port 23 which is the default for the Telnet program.

share|improve this answer
    
Thanks, it worked. –  funerr Jul 19 '12 at 15:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.