TCP is byte stream oriented, not message oriented. So you could end up with the data callback could give anywhere from one byte at a time to clumping every byte sent together, or anywhere in between. UDP is message oriented, but messages may be out of order or lost.
On Sun, Aug 25, 2013 at 5:44 AM, James L. <[email protected]> wrote: > Need some advice on NodeJS receiving data from Java NIO socket, I found > that sometime NodeJS will capture more than one message and outputs in the > same line instead of multiple lines especially if more than one message are > sending at the same milliseconds. Can MQTT overcomes it? > > *NodeJS code:* > var server = net.createServer(); > server.listen(PORT, HOST); > server.on('connection', function(sock) { > sock.setNoDelay(true); > sock.on('data', function(data) { > $('#console span').text('>'+data); > }); > sock.on('error', function (exc) { > console.log("ignoring exception: " + exc); > }); > }); > > *Output:* > >Test1 > >Test2Test3Test4 <--- Why won't this output correctly? > >Test5 > > -- > -- > 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. > -- -- 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.
