I'm aware of netstrings, and in fact, my approach is similar. A frame would 
be of the format [client_id][frame_data] . E.g.

[123][ABCDEF]

My question, though is, if I had no way to guarantee that the message will 
not be split up into chunks arbitrarily, firing multiple read callbacks, 
then my message could get broken up like this:

[123][ABC]
[DEF]

When I get [DEF] in my read callback, I would have no idea that this data 
came from client 123.


On Wednesday, September 2, 2015 at 2:27:29 PM UTC+5:30, Saúl Ibarra 
Corretgé wrote:
>
> On 02/09/15 10:53, KN wrote: 
> > Thanks for the clarification. What I'm essentiatlly trying to do is 
> > allow the server to handle requests from multiple clients. Currently, my 
> > approach is to send the message from the client in frames, with each 
> > frame containing a request_id followed by the frame data, so that the 
> > server can then assemble the entire message before responding to the 
> > client. 
> > 
> > I'm afraid that if the chunking happens in the middle of the frame, then 
> > I would lose the header which will contain the requestId, and so my 
> > server would not be able to assemble the frames properly. 
> > 
>
> You could use something like netstrings [0] or any other delimiting 
> mechanism, such as ending every line with CRLF and separating messages 
> with CRLFCRLF. 
>
> [0]: http://cr.yp.to/proto/netstrings.txt 
>
> -- 
> 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/d/optout.

Reply via email to