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)
size_t msg_controllen; /* ancillary data buffer len */
int msg_flags; /* flags on received message */
}
msg_control specifies a buffer to receive any ancillary data sent along with the message. Ancillary data
consists of a sequence of pairs, each consisting of a cmsghdr structure followed by a data array. The data
array contains the ancillary data message, and the cmsghdr structure contains descriptive information
that allows an application to correctly parse the data. cmsghdr has the following structure:
(UNIX 98)
struct cmsghdr {
socklen_t cmsg_len; /* data byte count, including hdr*/
int cmsg_level; /* originating protocol */
int cmsg_type; /* protocol-specific type */
}
Obsolescent (UNIX 95)
struct cmsghdr {
size_t cmsg_len; /* data byte count, including hdr*/
int cmsg_level; /* originating protocol */
int cmsg_type; /* protocol-specific type */
}
The supported value for cmsg_level is SOL_SOCKET, and the supported value for cmsg_type is
SCM_RIGHTS. Together they indicate that the data array contains the access rights to be received. Access
rights are supported only for AF_UNIX. Access rights are limited to file descriptors of size int. If ancillary
data are not being transferred, set the msg_control field to NULL, and set the msg_controllen field to 0.
The flags parameter accepts a new value,
MSG_WAITALL , which requests that the function block until the
full amount of data requested can be returned. The function may return a smaller amount of data if a sig-
nal is caught, the connection is terminated, or an error is pending for the socket.
On successful completion of recvmsg(), the msg_flags member of the message header is the bitwise-
inclusive OR of all of the following flags that indicate conditions detected for the received message.
MSG_EOR End of record was received (if supported by the protocol).
MSG_OOB Out-of-band data was received.
MSG_TRUNC Normal data was truncated.
MSG_CTRUNC Control data was truncated.
DEPENDENCIES
AF_CCITT
recvfrom() is supported; however, the from and fromlen parameters are ignored (i.e., it works in the
same manner as recv()).
The O_NDELAY fcntl() call is not supported over X.25 links. Use the FIOSNBIO ioctl() call
instead to enable nonblocking I/0.
RETURN VALUE
recv(), recvfrom(), and recvmsg() return the following values:
n Successful completion. n is the number of bytes received.
0 The socket is blocking and the transport connection to the remote node failed.
-1 Failure. errno is set to indicate the error.
ERRORS
If recv(), recvfrom(),orrecvmsg() fails, errno is set to one of the following values.
[EAGAIN] Non-blocking I/O is enabled using O_NONBLOCK flag with fcntl() and the
receive operation would block, or the socket has an error that was set asynchro-
nously. An asynchronous error can be caused by a gateway failing to forward a
datagram because the datagram exceeds the MTU of the next-hop network and
the "Dont Fragment" (DF) bit in the datagram is set. (See
SO_PMTU in
HP-UX Release 11i: December 2000 4 Section 2257
___
___