Okay, maybe that's it.  I'm using windows 7.  Is the line buffering in the 
node documentation?  Thanks.

On Friday, September 21, 2012 7:09:10 PM UTC-4, Nathan Rajlich wrote:
>
> What are you using to connect to your server? Telnet? Is this Windows or 
> Unix? I think I remember hearing in the past that the Windows version of 
> Telnet sends characters immediately instead of line-buffering. This *could* 
> be the case, and if it is, then your chat server would need to be extended 
> to buffer lines and "boardcast" on newlines.
>
> On Fri, Sep 21, 2012 at 1:54 PM, gswartz 
> <[email protected]<javascript:>
> > wrote:
>
>> I'm going through the O'Reilly node - up and running book.  In chapter 2 
>> they have code to put together a chat server.  It's simple enough and 
>> though mine is somewhat working, the output doesn't match what they show. 
>>  In the example, it shows that when a client enters some data it's written 
>> to the other clients terminal window as a full string.  In my case it 
>> writes out each character instead of waiting until I hit the enter key. 
>>  From what I can see, my code is the same as the book so I'm not sure why 
>> the output is different.  Can anyone see the problem?   Thanks.
>>
>> var net = require("net");
>>
>> var chatServer = net.createServer(), clientList = [];
>>
>> chatServer.on("connection", function(client){
>>  client.name = client.remoteAddress + ":" + client.remotePort;
>>  clientList.push(client);
>>
>> client.write("Hi " + client.name + "!\n");
>>  client.on("data", function(data){
>> broadcast(data, client);
>>  });
>> });
>>
>> function broadcast(message, client){
>> for (var i = 0; i < clientList.length; i++){
>>  if (client !== clientList[i]){
>> clientList[i].write(client.name + " says " + message); 
>>  }
>> }
>> }
>>
>> chatServer.listen(9000);
>>
>> -- 
>> 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]<javascript:>
>> To unsubscribe from this group, send email to
>> [email protected] <javascript:>
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>
>
>

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

Reply via email to