Previous topic |
Next topic |
Contents |
Contact z/OS |
Library |
PDF
recvmsg() z/OS Communications Server: IP Sockets Application Programming Interface Guide and Reference SC27-3660-00 |
|
The recvmsg() call receives messages on the socket with descriptor s and stores the messages in an array of message headers. For datagram protocols, recvmsg() returns the source address associated with each incoming datagram. For connection-oriented protocols like TCP, getpeername() returns the address associated with the remote end of the connection.
A message header is defined by structure msghdr.
The definition of this structure can be found in the SOCKET.H header
file and contains the following elements:
This call returns the length of the data received. If data is not available for socket s, and s is in blocking mode, the recvmsg() call blocks the caller until data arrives. If data is not available, and s is in nonblocking mode, recvmsg() returns a -1 and sets errno to EWOULDBLOCK. See fcntl() or ioctl() to see how to set nonblocking mode. If a datagram packet is too long to fit in the supplied buffer, datagram sockets discard extra bytes. Stream sockets act like streams of information with no boundaries separating data. For example, if applications A and B are connected with a stream socket, and Application A sends 1000 bytes, each call to this function can return 1 byte, or 10 bytes, or the entire 1000 bytes. Therefore, applications using stream sockets should place this call in a loop, and call this function until all data has been received. Return valuesIf successful, the length
of the message in bytes is returned. The value 0 indicates that
the connection is closed. The value -1 indicates an error. Errno identifies
the specific error.
Related callsconnect(), fcntl(), getsockopt(), ioctl(), read(), readv(), recv(), recvfrom(), select(), selectex(), send(), sendmsg(), sendto(), setsockopt(), socket(), write(), writev() |
Copyright IBM Corporation 1990, 2014
|