Saúl, thanks for the response.

Even if I preallocate the buffer, it still isnt clear how to do it in
libuv. Here's how I would do it in plain C: http://pastebin.com/TAuxUqP7

As you can see, its a loop where each iteration reads the size then the data.
What would be the best way to achieve the same behavior in libuv?


Here is the first thing that comes to mind :-) When you allocate a handle for the connection, attach a struct to the ->data pointer which contains the count, following_msg_size and buf. Then start reading. In the alloc callback, return the slice of the buffer you see fit, based on the count and following_msg_size values you have. When you get to the point where count is >= that following_msg_size, call parse_msg and reset count an following_msg_size.

I hope that works!


Cheers,

--
Saúl Ibarra Corretgé
http://bettercallsaghul.com

--
You received this message because you are subscribed to the Google Groups 
"libuv" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/libuv.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to