-------------------- chatServer.js --------------------------
var net = require('net');
var chatServer = net.createServer();
chatServer.on('connection', function(client){
console.log('A user is connected to server');
client.write('Hi!\n');
client.write('Bye!\n');
client.end();
});
chatServer.listen(9000);
console.log('Chat server started\n');
I have written this file and run the node server using this command : node
chatServer.js
and I opened the browser and join to 127.0.0.1:9000
the result that I expected is :
$ ~: node chatServer.js
Chat server started
A user is connected to server.
but I meet the messages so many
$ ~: node chatServer.js
Chat server started
A user is connected to server.
A user is connected to server.
A user is connected to server.
A user is connected to server.
Please let me know when you have chance.
Have a nice day
Thanks!
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.