Understanding socket calls send() and recv()

From: Rookie (dominicjoseph_at_rediffmail.com)
Date: 10/14/04


Date: Wed, 13 Oct 2004 17:32:43 -0700

Hi,

I had a question about send() and recv() calls. Suppose A and B have
established a connection (TCP sockets). Now if A send()s data to B, but at
that moment B is busy doing something else. Once B completes its task it
executes a recv() - will this let B get the data that A send? Or is it
absolutely essential that B be ready to recv() data when A sends it?

My understanding is that the incoming data is stored in a buffer on B's
machine and when the application (B in this case) does a recv(), this data
is then given to the application from the buffer. Correct me if I am wrong.

However if this understanding is correct then if a sender (A) is constantly
sending, I guess it will cause a buffer overflow at B - does TCP handle this
by asking the sender not to send anymore data or do we have to handle this
in the application? Also what is this buffer size? Is there any way to
programmatically set it?

I hope to hear from someone on this, soon. Thanks!



Relevant Pages

  • Re: BSD sockets: recv with MSG_WAITALL should return EWOULDBLOCK?
    ... (I am not convinced it is much use for blocking sockets ... many bytes as the size argument to recv() or to close the connection ... And this sounds like 'if you are using a buffer size that doesn't ... Another frame arrives and more data is queued to the socket buffer. ...
    (comp.unix.programmer)
  • Re: TdiBuildReceive question
    ... Irp->IoStatus.Information < the size of the buffer. ... then it is better to fill it as much as possible, and not complete the recv() ... To prevent such a time loss, the TCP protocol has a PSH bit ... PSH means - "the sender does not know when the next bytes will ...
    (microsoft.public.development.device.drivers)
  • Re: recv WSAENOBUFS error
    ... cross-posting, I did cross-post it initially, but I just started using ... it always asks for the "packet length" amount in the call to recv. ... You can set kernel-mode buffer with setsockopt but you'll quickly finish ...
    (microsoft.public.win32.programmer.kernel)
  • Re: recv WSAENOBUFS error
    ... it always asks for the "packet length" amount in the call to recv. ... You can set kernel-mode buffer with setsockopt but you'll quickly finish ... your non-page (kernel) memory if you'll start to do it. ...
    (microsoft.public.win32.programmer.networks)
  • Re: recv WSAENOBUFS error
    ... it always asks for the "packet length" amount in the call to recv. ... You can set kernel-mode buffer with setsockopt but you'll quickly finish ... your non-page (kernel) memory if you'll start to do it. ...
    (microsoft.public.win32.programmer.kernel)