recv.2 (2010 09)

r
recv(2) recv(2)
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
signal 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.
X/Open Sockets Compilation Environment
See xopen_networking(7).
DEPENDENCIES
AF_CCITT
recvfrom() is supported; however, the from and fromlen parameters are ignored (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, or the remote
side of a connection-based socket has performed an orderly shutdown and there is no more
data to read (the socket has reached the end of its data stream). Sockets with the
O_NDELAY
flag set may also return 0 at any time when there is no data available.
-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 asyn-
chronously. An asynchronous error can be caused by a gateway failing to for-
ward a datagram because the datagram exceeds the MTU of the next-hop net-
work and the "Don’t Fragment" (DF) bit in the datagram is set. (See
SO_PMTU
in getsockopt (2).)
[EBADF] The argument s is an invalid descriptor.
[ECONNRESET] A connection was forcibly closed by a peer.
[EFAULT] An invalid pointer was specified in the buf , from,orfromlen parameter, or in
the msghdr structure.
[EINTR] The receive was interrupted by delivery of a signal before any data was avail-
able for the receive.
[EINVAL] The len parameter or a length in the msghdr structure is invalid; or no data is
available on receive of out of band data.
[EMFILE] The number of file descriptors available to the calling process has been
exceeded.
[EMSGSIZE] A length in the msghdr structure is invalid.
[ENOBUFS] Insufficient resources were available in the system to perform the operation.
[ENOPROTOOPT] The remote system or an intermediate system in the communications path
does not support a protocol option sent by the local system. This option may
have been set using a
getsockopt() or setsockopt() call, or set as a
system parameter.
HP-UX 11i Version 3: September 2010 5 Hewlett-Packard Company 5