COHERENT manpages

This page displays the COHERENT manpage for recvfrom() [Receive a message from a socket].

List of available manpages
Index


recvfrom() -- Sockets Function (libsocket)

Receive a message from a socket
#include <sys/compat.h>
#include <sys/socket.h>
#include "socketvar.h"
int recvfrom (socket, buffer, length, flags, address, addrlen)
int socket; char *buffer; int length; int flags;
sockaddr_t *from; int *alen;

recvfrom()  receives  messages from  another  socket.   Unlike the  related
function recv(), recvfrom()  receives data regardless of whether the socket
is connected or not.

socket  is the  file descriptor  of the  socket from which  data are  to be
received.  It may  or may not be connected.  buffer  is the chunk of memory
in user  space into which  the data are  to be written; it  is length bytes
long.  If a received message is  longer than length bytes, excess bytes can
be discarded,  depending on the  type of socket  from which the  message is
received.  If from is not NULL, recvfrom() initializes it to the the source
address of  the message.   It initializes  alen to the  size of  the buffer
associated with  address, and modifies  it upon return  to the size  of the
address stored there.

If no  messages are waiting  at socket, recvfrom()  waits for a  message to
arrive, unless the socket is nonblocking.   In this case, it returns -1 and
sets errno, as described below.

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 socket. The  data are  returned but
     remain  on socket;  therefore, another  call  to recvfrom()  or recv()
     retrieves the same data.

If all goes  well, recvfrom() returns the number of  bytes received.  If an
error occurs, it returns -1 and sets errno to one of the following values:

EBADF
     socket is an invalid descriptor.

ENOTSOCK
     socket is the descriptor of a file, not a socket.

EINTR
     The operation was interrupted by  delivery of a signal before any data
     was available to be received.

EAGAIN
     socket  is  marked non-blocking,  but  the  requested operation  would
     block.

ENOMEM
     Too little user memory is available to complete the operation.

See Also

libsocket,
recv()

Notes

At present, the COHERENT  implementation of recvfrom() always behaves as if
address were initialized to NULL.