Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js TCP input buffering

I'm not sure I got this right yet, but as I understand it, when I attach a handler to the data event, it gives me all the data it got until then. The problem is, how do I handle buffering that data, as Node.js might give me less that 4 bytes at a time (which is the minimum I need), especially when there will be multiple concurrent requests?

like image 665
Bogdacutu Avatar asked Sep 28 '26 09:09

Bogdacutu


1 Answers

I think this problem has been tackled in this article: http://openmymind.net/2012/1/12/Reading-From-TCP-Streams/

Links to the 2 solutions described there:

  • https://github.com/karlseguin/redispy/blob/master/lib/reader.coffee
  • https://gist.github.com/1598236
like image 184
alessioalex Avatar answered Sep 30 '26 02:09

alessioalex