Go to the previous, next section.
int recv(int s, void *buf, int len, unsigned int
flags);
int recvfrom(int s, void *buf, int len, unsigned
int flags struct sockaddr *from, int *fromlen);
int recvmsg(int s, struct msghdr *msg, unsigned int
flags);
s: [in] the socket to read from.
buf: [out] points to a buffer where to put the information read.
len: [in] the capacity of the buffer.
flags: [in] several options (see description).
from: [out] points to an area where to store the peer address. If
NULL
, the peer address is not stored.
fromlen: [in out] on entry, points to a number indicating the capacity of from. On return, points to an area where to store the actual length of from.
msg: [out] points to an area where to store the incomming message header.
recv
is usually used to receive messages form a
connection-oriented socket. It is equivalent to recvfrom with
from
set to NULL
.
recvfrom
and recvmsg
are used for connection-less or
connection-oriented sockets.
These calls block if there is no message to receive unless the socket is non-blocking.
The flags parameter may have the following values:
MSG_OOB
MSG_PEEK
MSG_WAITALL
recvmsg
is not yet implemented in Linux.
On success, the number of bytes received. On error, the call returns -1
and sets errno
to one of the following values:
EBADF
, ENOTCONN
, ENOTSOCK
,
EWOULDBLOCK
, EINTR
or EFAULT
.
Go to the previous, next section.