Node:Receiving Data, Next:Socket Data Options, Previous:Sending Data, Up:Transferring Data
The recv
function is declared in the header file
sys/socket.h
. If your flags argument is zero, you can
just as well use read
instead of recv
; see I/O Primitives.
int recv (int socket, void *buffer, size_t size, int flags) | Function |
The recv function is like read , but with the additional
flags flags. The possible values of flags are described
in Socket Data Options.
If nonblocking mode is set for socket, and no data are available to
be read, This function returns the number of bytes received, or
This function is defined as a cancellation point in multi-threaded programs, so one has to be prepared for this and make sure that allocated resources (like memory, files descriptors, semaphores or whatever) are freed even if the thread is canceled. |