On 06/09/2012, at 23:11, Mark Volkmann wrote:
> I'm trying to understand a detail about net.createServer().
> In the code below, how is it that Node guarantees that no data will be lost
> if a client immediately writes to its socket when it connects to this server?
> Is something buffering writes from the client until the callback function
> passed to net.createServer completes?
> Does the server not read from its socket until that callback completes
> because something that enables reads is waiting on the event queue?
>
> var net = require('net');
>
> var server = net.createServer(function (socket) {
>
> // Could the client write to the socket before the next call completes?
>
> socket.on('data', function (data) {
> console.log('received "' + data + '"');
> });
> });
>
> server.listen(8123, function () {
> console.log('listening');
> });
My understanding is that node won't/shouldn't emit/dispatch any 'data' events
to the socket 'socket' until *after* having called cb(socket), 'cb' being the
callback function passed on to .createServer(cb).
--
Jorge.
--
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