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".


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

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


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?


The telnet command is wrong. Should be telnet 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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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