Syntax
#include <sys/types.h>
#include <sys/socket.h>
int recvmsg(int socket_descriptor,
struct msghdr *message_structure,
int flags)
|
The recvmsg() function is used to receive data or descriptors or both through a connected or unconnected socket.
Parameters
struct msghdr [
caddr_t msg_name;
int msg_namelen;
struct iovec *msg_iov;
int msg_iovlen;
caddr_t msg_accrights;
int msg_accrightslen;
];
The msg_name and msg_namelen fields contain the address and address length to which the message is sent. For further information on the structure of socket addresses, see the Sockets Programming book. If the msg_name field is set to a NULL pointer, the address information is not returned.
The msg_iov and msg_iovlen fields are for scatter/gather I/O.
The msg_accrights and msg_accrightslen fields are used to pass descriptors. The msg_accrights field is a list of zero or more descriptors, and msg_accrightslen is the total length (in bytes) of the descriptor list.
Return Value
recvmsg() returns an integer. Possible values are:
Error Conditions
When recvmsg() fails, errno can be set to one of the following:
The socket pointed to by the socket_descriptor parameter is using a connection-oriented transport service, and a connect() was previously completed. The process, however, does not have the appropriate privileges to the objects that were needed to establish a connection. For example, the connect() required the use of an APPC device that the process was not authorized to.
If the msg_accrights and msg_accrightslen fields were specified, this error indicates that this job does not have the appropriate privileges required to receive the descriptor. When this occurs, the descriptor is reclaimed by the system and the resource that it represented is closed.
This error code indicates that the transport provider ended the connection abnormally because of one of the following:
The system detected an address which was not valid while attempting to access the message_structure parameter or a field within the structure pointed to by the message_structure parameter.
This error code indicates one of the following:
The msg_iovlen field specifies a value that is greater than [MSG_MAXIOVLEN] (defined in <sys/socket.h>).
This error code is returned only on sockets that use a connection-oriented transport service.
This error code indicates one of the following:
A non-blocking connect() was previously issued that resulted in the connection establishment timing out. No connection is established. This error code is returned only on sockets that use a connection-oriented transport service.
Error Messages
Usage Notes
Note: The recvmsg() API will not block unless a data buffer is specified.
Related Information
| Top | Sockets APIs | APIs by category |
| [Information Center Home Page | Feedback ] | [Legal | AS/400 Glossary] |