Syntax
#include <sys/types.h>
#include <sys/socket.h>
int sendto(int socket_descriptor,
char *buffer,
int buffer_length,
int flags,
struct sockaddr *destination_address,
int address_length)
|
The sendto() function is used to send data through a connected or unconnected socket.
Parameters
struct sockaddr {
u_short sa_family;
char sa_data[14];
};
The sa_family field identifies the address family to which the address belongs, and sa_data is the address whose format is dependent on the address family.
Return Value
sendto() returns an integer. Possible values are:
Error Conditions
When sendto() 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, and 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 passed in as an argument on the sendto(). 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 buffer or destination_address 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 on sockets that use the AF_UNIX address family.
The data to be sent could not be sent atomically because the total size of the data to be sent is too large.
This error code refers to the destination address, and can only be returned on 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 on sockets that use the AF_UNIX address family.
This error code refers to the destination address, and can only be returned on 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 on sockets that use the AF_UNIX address family.
This error code indicates one of the following:
This error code is only returned on sockets that use the AF_UNIX address family.
Error Messages
Usage Notes
Note: The destination_address and address_length 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] |