On Wed, Sep 2, 2015 at 8:26 AM, KN <[email protected]> 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