send/recv socket calls

From: DJP (dominicjoseph_at_rediffmail.com)
Date: 10/01/04


Date: Fri, 1 Oct 2004 02:13:08 -0700

Hi,

I was just trying to understand the send/recv socket calls. Does a send call
block if the receiver hasn't executed a recv for the number of bytes that a
sender is sending? For example if A sends 50 bytes to B and the code in B
just does a recv for 10, what exactly is going to happen? (I am using TCP
SOCK_STREAM) Does A just pretend that all the byes were sent or does it
block until the receiver receives all the bytes.

I am basically trying to get at the logic that I should be building into my
receiver. If I do not know how much data I am going to receive. What is the
logic I should use at the receiver in determining how many bytes to recv or
read from the byte stream?

I hope someone can help me with this. Thanks a lot!



Relevant Pages

  • Re: wierd send/recv problem
    ... stream of bytes - it knows no "message" boundaries. ... If you call sendwith 1024 bytes, the recv() on ... The architecture of my receiver is as follows ... So basically, first message reaches properly, second message doesnt go ...
    (microsoft.public.win32.programmer.networks)
  • Re: How hard is socket programming?
    ... s = socket() - create a socket handle ... as many recv calls as necessary, which is somewhere between 1 and some unknown value n ... It is a STREAM protocol, ... chunks of data, based on how the sender and receiver stacks, and all intermediate routers, ...
    (microsoft.public.vc.mfc)
  • Re: Socket differences between localhost and LAN (or Internet)
    ... Recv() is not reliable, ok, is the Sendreliable too? ... I see that the total amount of received bytes is not what I expected, ... The other bytes of the transmission are in transit. ... along the path from sender to receiver. ...
    (microsoft.public.vc.ide_general)
  • Re: wierd send/recv problem
    ... Now how about the receiver code....how should that work?? ... you will need to encode the boundaries in your ... Do you mean that I'll have to call recv again to receive the message if ... stream of bytes - it knows no "message" boundaries. ...
    (microsoft.public.win32.programmer.networks)
  • Re: sending images over a socket
    ... > A recv() call only returns the data received up to that point. ... > in the sockets implementation, ... > the receiver must fetch this length first, ... > - The sender and receiver always know exactly how much data is transferred ...
    (comp.unix.programmer)