* Re: recv()
[not found] <LFEIJFMKHCJIHBFOGINPCEIGCHAA.elapus@ntsp.nec.co.jp>
@ 2002-08-27 4:21 ` Manas Garg
2002-08-27 4:23 ` recv() Glynn Clements
1 sibling, 0 replies; 2+ messages in thread
From: Manas Garg @ 2002-08-27 4:21 UTC (permalink / raw)
To: linux-c-prog
On Tue Aug 27, 2002 at 10:41:01AM -0700, Earl R. Lapus wrote:
> When calling recv() you specify the maximum data
> size you want to receive, right? So if the actual data
> sent at the other end is larger... what happens to the
> rest of the data? Who manages the data?
It depends on the type of socket.
In case of TCP, recv() acts on all the data that has been received on
the socket and if it can get all the available data to the user (because
of the size of the buffer supplied to recv()), the remaining data will
be kept in kernel receive buffer for that particular socket.
In case of UDP, recv() acts on the data received in one datagram. If the
kernel can't return all the data of a datagram because of buffer size
constraints, it will discard the rest of the data that came as a part of
that datagram.
All this is clearly mentioned in the man page of recv(2).
/manas
http://www.chakpak.com
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: recv()
[not found] <LFEIJFMKHCJIHBFOGINPCEIGCHAA.elapus@ntsp.nec.co.jp>
2002-08-27 4:21 ` recv() Manas Garg
@ 2002-08-27 4:23 ` Glynn Clements
1 sibling, 0 replies; 2+ messages in thread
From: Glynn Clements @ 2002-08-27 4:23 UTC (permalink / raw)
To: Earl R. Lapus; +Cc: linux-c-prog
Earl R. Lapus wrote:
> I have a question about recv()...
> When calling recv() you specify the maximum data
> size you want to receive, right? So if the actual data
> sent at the other end is larger... what happens to the
> rest of the data? Who manages the data?
It depends upon the protocol. For TCP, subsequent data will be
returned by the next call to recv(); packet boundaries are irrelevant.
For UDP, the rest of the packet will be discarded, so you need to
ensure that the buffer is large enough to hold an entire packet.
--
Glynn Clements <glynn.clements@virgin.net>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-08-27 4:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <LFEIJFMKHCJIHBFOGINPCEIGCHAA.elapus@ntsp.nec.co.jp>
2002-08-27 4:21 ` recv() Manas Garg
2002-08-27 4:23 ` recv() Glynn Clements
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).