COHERENT manpages
This page displays the COHERENT manpage for recv() [Receive a message from a connected socket].
List of available manpages
Index
recv() -- Sockets Function (libsocket)
Receive a message from a connected socket
#include <sys/types.h>
#include <sys/socket.h>
int recv(socket, buffer, length, flags)
int socket;
char *buffer;
int length, flags;
The function recv() receives messages from a connected socket.
socket is the socket from which the messages are received. It must have
been created by the function socket(), and connected with the function
connect(). buffer points to the chunk of memory into which the message is
to be written; length gives the amount of allocated memory to which buffer
points.
flags ORs together either or both of the following flags:
MSG_OOB
Read any out-of-band data present on socket, rather than the regular,
in-band data.
MSG_PEEK
``Peek'' at the data present on the socket: the data are copied but
not erased from the socket, so another call to recv() or recvfrom()
retrieves the same data.
If all goes well, recv() returns the number of bytes it read from socket.
If something went wrong, it returns -1 and sets errno to one of the
following values:
EAGAIN
If no message is queued at socket, recv() normally waits for a message
to arrive (which is a blocking operation). socket, however, is marked
as non-blocking.
EBADF
socket does not identify a valid socket.
EINTR
A signal interrupted recv() before it could receive any data.
ENOMEM
Insufficient user memory was available to complete the operation.
ENOTSOCK
socket describes a file, not a socket.
See Also
connect(),
libsocket,
recvfrom(),
send(),
socket()