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)
Since both the fcntl() O_NONBLOCK and O_NDELAY flags and ioctl() FIOSNBIO request are sup-
ported, some clarification on how these features interact is necessary. If the O_NONBLOCK or
O_NDELAY flag has been set, recv() requests behave accordingly, regardless of any FIOSNBIO
requests. If neither the O_NONBLOCK flag nor the O_NDELAY flag has been set, FIOSNBIO requests
control the the behavior of recv().
By default nonblocking I/O is disabled.
select() can be used to determine when more data arrives by selecting the socket for reading.
The flags parameter can be set to MSG_PEEK, MSG_OOB, both, or zero. If it is set to MSG_PEEK, any
data returned to the user still is treated as if it had not been read. The next recv() rereads the same
data. The MSG_OOB flag is used to receive out-of-band data. For TCP SOCK_STREAM sockets, both the
MSG_PEEK and MSG_OOB flags can be set at the same time. The MSG_OOB flag value is supported for
TCP SOCK_STREAM sockets only. MSG_OOB is not supported for AF_UNIX or AF_VME_LINK sockets.
A read() call made to a socket behaves in exactly the same way as a recv() with flags set to zero.
AF_CCITT Only
Connections in the address family AF_CCITT support message-based sockets only. Although the user
specifies connection-based communications (SOCK_STREAM), the X.25 subsystem communicates via mes-
sages. This address family does not support SOCK_DGRAM socket types.
Normally, each recv() returns one complete X.25 message. If the socket is in nonblocking mode,
recv() behaves as described above. Note that if the user specifies len less than the actual X.25 message
size, the excess data is discarded and no error indication is returned. The size of the next available mes-
sage as well as the state of MDTF, D, and Q bits can be obtained with
ioctl(X25_NEXT_MSG_STAT).
Connections of the address family AF_CCITT receive data in the same way as message-based connections
described above, with the following additions and exceptions:
recvfrom() is supported; however, the from and fromlen parameters are ignored (that is, it works
in the same manner as recv()).
To receive a message in fragments of the complete X.25 message, use
ioctl(X25_SET_FRAGMENT_SIZE)
. The state of the MDTF bit is 1 for all except the last frag-
ment of the message.
The
MSG_OOB flag is supported.
The MSG_PEEK flag is supported; the two ags can be combined.
If a message is received that is larger than the user-controlled maximum message size (see
af_ccitt(7F)), the X.25 subsystem RESETs the circuit, discards the data, and sends the out-of-band
event OOB_VC_MESSAGE_TOO_BIG
to the socket.
_XOPEN_SOURCE_EXTENDED Only
For
X/Open Sockets, the msghdr structure has the following form:
(UNIX 98)
struct msghdr {
void *msg_name; /* optional address */
socklen_t msg_namelen; /* size of address */
struct iovec *msg_iov; /* scatter array for data */
int msg_iovlen; /* # of elements in msg_iov */
void *msg_control; /* ancillary data, see below */
socklen_t msg_controllen; /* ancillary data buffer len */
int msg_flags; /* flags on received message */
}
Obsolescent (UNIX 95)
struct msghdr {
void *msg_name; /* optional address */
size_t msg_namelen; /* size of address */
struct iovec *msg_iov; /* scatter array for data */
int msg_iovlen; /* # of elements in msg_iov */
void *msg_control; /* ancillary data, see below */
Section 2256 3 HP-UX Release 11i: December 2000
___
___