Syntax
#include <sys/types.h>
#include <sys/socket.h>
int sendmsg(int socket_descriptor,
struct msghdr *message_structure,
int flags)
|
The sendmsg() function is used to send 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
sendmsg() returns an integer. Possible values are:
Error Conditions
When sendmsg() fails, errno can be set to one of the following:
The process does not have the appropriate privileges to the destination address.
A socket with an address family of AF_INET is using a connectionless transport service, the socket was not bound. The system tried to bind the socket but could not because a port was not available.
This error code can only be returned on sockets that use a connectionless transport service.
A destination address has not been associated with the socket pointed to by the socket_descriptor parameter and a destination address was not set in the msghdr structure (pointed to by the message_structure parameter). This error code can only be returned on sockets that use a connectionless transport service.
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 can only be returned on sockets that use a connectionless transport service.
This error code can only be returned on sockets that use a connectionless transport service.
This error code indicates one of the following:
A destination address was set, but the socket pointed to by the socket_descriptor parameter already has a destination address associated with it.
This error code refers to the destination address, and can only be returned by sockets that use the AF_UNIX address family.
This error code indicates one of the following:
This error code refers to the destination address, and can only be returned by sockets that use the AF_UNIX address family.
This error code can only be returned on sockets that use a connectionless transport service.
This error code can only be returned on sockets that use a connectionless transport service.
This error code refers to the destination address, and can only be returned by sockets that use the AF_UNIX address family.
This error code refers to the destination address, and can only be returned by sockets that use the AF_UNIX address family.
This error code can only be returned on sockets that use a connection-oriented transport service.
This error code refers to the destination address, and can only be returned by sockets that use the AF_UNIX address family.
This error code indicates one of the following:
Error Messages
Usage Notes
Note: The msg_name and msg_namelen fields are ignored if the socket is using a connection-oriented transport service.
Related Information
| Top | Sockets APIs | APIs by category |
| [Information Center Home Page | Feedback ] | [Legal | AS/400 Glossary] |