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.

On Wednesday, September 2, 2015 at 2:02:55 PM UTC+5:30, Ben Noordhuis wrote:
>
> On Wed, Sep 2, 2015 at 8:26 AM, KN <[email protected] <javascript:>> 
> wrote: 
> > Hello, 
> > 
> > I have a simple non-blocking TCP echo server implemented that I'm able 
> to 
> > connect via telnet. 
> > 
> > When I paste text into my telnet session and hit Enter, uv_read_cb is 
> > triggerred twice sometimes on the server. 
> > 
> > The documentation says that "The uv_read_cb callback will be made 
> several 
> > times until there is no more data to read or uv_read_stop() is called." 
> > 
> > However, is this is a behavior I can control and if so what should I do? 
> For 
> > e.g. I want the read callback to be triggerred only once 
> deterministically 
> > with the content that I paste into my telnet session. 
> > 
> > Or, is it that the telnet program is sending the text in 2 chunks, and 
> which 
> > is why the echo server is invoking the read callback twice? 
> > 
> > Thanks, 
> > 
> > KN. 
>
> Either telnet or the kernel ends up splitting the message because it's 
> too large to fit in a single TCP packet*, or you return a too small 
> buffer from your uv_alloc_cb. 
>
> Regardless of the cause, your application needs to be ready to handle 
> partial data because it's always possible for a chunk of data to get 
> split into two or more packets. 
>

-- 
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