If the server accepts the connection BEFORE connListener is called, then it
seems possible that the client could send a message before the server
registers for data events. That's why it seems that the client queues
messages until AFTER connListener completes. If I'm wrong about this, I'd
like to understand why.

On Fri, Sep 7, 2012 at 9:25 AM, ribao wei <riba...@gmail.com> wrote:

> Well, in this code connListener finishes execution without dataListener
> being registered. So I guess that is why the first message is lost.
>
> On Fri, Sep 7, 2012 at 10:21 AM, Mark Volkmann 
> <r.mark.volkm...@gmail.com>wrote:
>
>> On Fri, Sep 7, 2012 at 9:09 AM, Ben Noordhuis <i...@bnoordhuis.nl> wrote:
>>
>> The client queues write requests until the connection handshake is
>>> done. Said handshake is complete when the server accepts the
>>> connection, which node does right before it calls your connListener
>>> function.
>>
>>
>> If that is true then why is the first message from the client lost if I
>> do this?
>> Note that on my machine (OSX) the message is lost if the timeout is 2 ms
>> or more, but not if it is less than 2.
>> Maybe the client queues write requests until the connListener function
>> completes.
>>
>> server.js
>>
>> var net = require('net');
>> function dataListener(data) {
>>   console.log('received', data.toString());
>> }
>> function connListener(socket) {
>>   setTimeout(function () {
>>     socket.on('data', dataListener);
>>   }, 2);
>> }
>> var server = net.createServer(connListener);
>> server.listen(8019);
>>
>> client.js
>>
>> var net = require('net');
>> var socket = net.connect(8019);
>> socket.write('Is this lost?');
>>
>> --
>> R. Mark Volkmann
>> Object Computing, Inc.
>>
>> --
>> 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 nodejs@googlegroups.com
>> To unsubscribe from this group, send email to
>> nodejs+unsubscr...@googlegroups.com
>> 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 nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>



-- 
R. Mark Volkmann
Object Computing, Inc.

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to