TCP/IP Programming Manual

nsent
return value; the number of bytes sent. This is the return value. If this number is less than length,
the operation should be retried with the remaining data.
If the call is not successful, —1 is returned and the external variable errno is set as indicated
in Errors (page 178).
socket
input value; specifies the socket number for the socket, as returned by the call to the socket
function.
buffer_ptr
input value; points to the data to be sent.
buffer_length
input value; the size of the buffer pointed to by buffer_ptr.
flags
input value; specifies whether the outgoing data should be sent to the destination if routing is
required. This parameter can be one of the following messages:
Send this message only if the destination is located on the local network; do not send
the message through a gateway.
MSG_DONTROUTE
No flag; send the message to the destination, even if the message must be routed.0
sockaddr_ptr
input value; points to the remote address and port number (based on the structure sockaddr_in
or sockaddr_in6) to which the data is sent.
sockaddr_length
input value; maintained only for compatibility and should be a value indicating the size, in
bytes, of the structure (the remote address and port number pointed to by sockaddr_ptr.
Errors
If an error occurs, the return value is set to -1 and the external variable errno is set to one of the
following values:
Permission denied for broadcast because SO_BROADCAST is not set.EACCES
The message was too large to be sent atomically, as required by the socket options.EMSGSIZE
The specified socket was connected.EISCONN
The specified socket was shut down.ESHUTDOWN
The destination network was unreachable.ENETUNREACH
An invalid argument was specified.EINVAL
Usage Guidelines
This is a waited call; your program pauses until the operation is complete.
Declare the sockaddr_ptr variable as struct sockaddr_in6 * for IPv6 use or as
struct sockaddr_storage * for protocol-independent use. In C, when you make the
call, cast the variable to sockaddr.
Examples
See Client and Server Programs Using UDP (page 219) for examples that call sendto.
178 Library Routines