HP-UX Reference (11i v1 00/12) - 2 System Calls (vol 5)

__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man2/!!!intro.2
________________________________________________________________
___ ___
r
recv(2) recv(2)
the user as soon as it becomes available, and no data is discarded. See the AF_CCITT Only subsection
below for a list of the exceptions to this behavior for connections in the address family AF_CCITT.
recvmsg() performs the same action as recv(), but scatters the read data into the buffers specified in
the msghdr structure (see _XOPEN_SOURCE_EXTENDED Only below). This structure is defined in
<sys/socket.h> and has the following form (HP-UX BSD Sockets Only):
struct msghdr {
caddr_t msg_name; /* optional address */
int msg_namelen; /* size of address */
struct iovec *msg_iov; /* scatter array for data */
int msg_iovlen; /* # of elements in msg_iov */
caddr_t msg_accrights; /* access rights */
int msg_accrightslen; /* size of msg_accrights */
}
msg_name points to a sockaddr structure in which the address of the sending socket is to be stored, if
the socket is connectionless; msg_name may be a null pointer if no name is specified. msg_iov specifies the
locations of the character arrays for storing the incoming data. msg_accrights specifies a buffer to receive
any access rights sent along with the message. Access rights are limited to file descriptors of size int.If
access rights are not being transferred, set the msg_accrights field to NULL. Access rights are supported
only for AF_UNIX.
If no data is available to be received,
recv() waits for a message to arrive unless nonblocking mode is
enabled. There are three ways to enable nonblocking mode:
With the FIOSNBIO ioctl() request
With the O_NONBLOCK fcntl() flag
With the O_NDELAY fcntl() flag
Although the use of FIONBIO is not recommended, if nonblocking I/O is enabled using FIOSNBIO or the
equivalent
FIONBIO request (defined in <sys/ioctl.h>
and explained in ioctl(2), ioctl(5) and
socket(7)), the
recv() request completes in one of three ways:
If there is enough data available to satisfy the entire request, recv() completes successfully, having
read all of the data, and returns the number of bytes read.
If there is not enough data availableto satisfy the entire request,
recv() complete successfully, hav-
ing read as much data as possible, and returns the number of bytes it was able to read.
If there is no data available,
recv() fails and errno is set to [EWOULDBLOCK ].
If nonblocking I/O is disabled using
FIOSNBIO, recv() always executes completely (blocking as neces-
sary) and returns the number of bytes read.
If the O_NONBLOCK flag is set using fcntl() (defined in <sys/fcntl.h>
and explained in fcntl(2)
and fcntl(5)), POSIX-style nonblocking I/O is enabled. In this case, the
recv() request completes in one
of three ways:
If there is enough data available to satisfy the entire request, recv() completes successfully, having
read all the data, and returns the number of bytes read.
If there is not enough data available to satisfy the entire request, recv() completes successfully,
having read as much data as possible, and returns the number of bytes it was able to read.
If there is no data available,
recv() completes, having read no data, and returns 1 with
errno set
to [EAGAIN].
If the
O_NDELAY flag is set using fcntl() (defined in <sys/fcntl.h> and explained in fcntl(2) and
fcntl(5)), nonblocking I/O is enabled. In this case, the
recv() request completes in one of three ways:
If there is enough data available to satisfy the entire request, recv() completes successfully, having
read all the data, and returns the number of bytes read.
If there is not enough data available to satisfy the entire request, recv() completes successfully,
having read as much data as possible, and returns the number of bytes it was able to read.
If there is no data available, recv() completes successfully, having read no data, and returns 0.
If the O_NONBLOCK or O_NDELAY flag is cleared using fcntl(), the corresponding style of nonblocking
I/O, if previously enabled, is disabled. In this case, recv() always executes completely (blocking as neces-
sary) and returns the number of bytes read.
HP-UX Release 11i: December 2000 2 Section 2255
___
___