On Fri, Sep 7, 2012 at 3:35 PM, Mark Volkmann <[email protected]> wrote: > I don't doubt you. I just want to see that documented somewhere or clearly > see how that is enforced in the code. I have looked at net.js. It's not the > easiest code to follow. If it's clear from that code, I could use some > pointers on where to look. > > I'll try to make my concern more clear below with very simple code for > server.js and client.js that really runs. Run "node server" in one window > and "node client" in another. > The numbered comments indicate the order in which I expect the lines to > execute. > It seems clear to me that 4 could run before 5. If that happens, how is it > that the server still gets that message? Is the message being buffered until > connListener completes? > > server.js > > var net = require('net'); > function dataListener(data) { > console.log('received', data.toString()); > } > function connListener(socket) { > socket.on('data', dataListener); // 5 > } > var server = net.createServer(connListener); // 1 > server.listen(8019); // 2 > > client.js > > var net = require('net'); > var socket = net.connect(8019); // 3 > socket.write('Is this lost?'); // 4
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. -- 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
