Receives bytes from a connected socket and places them into a buffer.
#include <socket.h> int recv (int s, char *buf, int len, int flags);
The MSG_OOB flag allows out-of-band data to be received. If out-of- band data is available, it will be read before any other data that is available. If no out-of-band data is available, the MSG_OOB flag is ignored. Out-of-band data can be sent using send, sendmsg, and sendto.
The MSG_PEEK flag allows you to peek at the data that is next in line to be received without removing it from the system's buffers.
Data is sent by the socket's peer using the send, sendmsg, or sendto routines.
You may use the select routine to determine when more data arrives.
If no data is available at the socket, the receive call waits for data to arrive, unless the socket is nonblocking in which case a -1 is returned with the external variable errno set to EWOULDBLOCK.
See also read, send, sendmsg, sendto, and socket in this section.
x | The number of bytes received and placed in buf. |
0 | Indicates that a connection is broken or reset by its peer. |
-1 | Indicates an
error; errno is set to one of the following:
|