Manual Page Result
0
Command: sendto | Section: 2 | Source: Digital UNIX | File: sendto.2.gz
sendto(2) System Calls Manual sendto(2)
NAME
sendto - Sends messages through a socket
SYNOPSIS
#include <sys/socket.h>
ssize_t sendto ( int socket, const void *message, size_t
length, int flags, const struct sockaddr *dest_addr,
size_t dest_len );
[Digital] The following definition of the sendto() function does not
conform to current standards and is supported only for backward compat-
ibility (see standards(5)):
#include <sys/socket.h>
int sendto ( int socket, char *message_addr, int length,
int flags, struct sockaddr *dest_addr, int dest_len );
STANDARDS
Interfaces documented on this reference page conform to industry stan-
dards as follows:
sendto(): XPG4-UNIX
Refer to the standards(5) reference page for more information about in-
dustry standards and associated tags.
PARAMETERS
Specifies the unique name for the socket. Points to the address con-
taining the message to be sent. Specifies the size of the message in
bytes. Allows the sender to control the message transmission. The
flags value to send a call is formed by logically ORing the following
values, defined in the sys/socket.h file: Processes out-of-band data on
sockets that support out-of-band data. Sends without using routing ta-
bles. (Not recommended, for debugging purposes only.) Points to a
sockaddr structure, the format of which is determined by the domain and
by the behavior requested for the socket. The sockaddr structure is an
overlay for a sockaddr_in or sockaddr_un structure, depending on which
of the supported address families is active.
[Digital] If the compile-time option _SOCKADDR_LEN is defined
before the sys/socket.h header file is included, the sockaddr
structure takes 4.4BSD behavior, with a field for specifying the
length of the socket address. Otherwise, the default 4.3BSD
sockaddr structure is used, with the length of the socket ad-
dress assumed to be 14 bytes or less.
If _SOCKADDR_LEN is defined, the 4.3BSD sockaddr structure is
defined with the name osockaddr. Specifies the length of the
sockaddr structure pointed to by the dest_addr parameter.
DESCRIPTION
The sendto() function allows an application program to send messages
through an unconnected socket by specifying a destination address.
To broadcast on a socket, issue a setsockopt() function using the
SO_BROADCAST option to gain broadcast permissions.
Use the dest_addr parameter to provide the address of the target.
Specify the length of the message with the length parameter.
If the sending socket has no space to hold the message to be transmit-
ted, the sendto() function blocks unless the socket is in a nonblocking
I/O mode.
Use the select() function to determine when it is possible to send more
data.
RETURN VALUES
Upon successful completion, the sendto() function returns the number of
characters sent. Otherwise, a value of -1 is returned, and errno is
set to indicate the error.
ERRORS
If the sendto() function fails, errno may be set to one of the follow-
ing values: Search permission is denied for a component of the path
prefix; or write access to the named socket is denied. Addresses in
the specified address family cannot be used with this socket. The
socket parameter is not valid. A connection was forcibly closed by a
peer. The dest_addr parameter is not in a writable part of the user
address space. A signal interrupted sendto before any data was trans-
mitted. An I/O error occurred while reading from or writing to the
file system. Too many symbolic links were encountered in translating
the pathname in the socket address. The message is too large to be
sent all at once, as the socket requires. A component of the pathname
does not name an existing file or the pathname is an empty string. The
socket is connection-oriented but is not connected. A component of the
path prefix of the pathname in address is not a directory. The socket
argument is associated with a socket that does not support one or more
of the values set in flags. The socket parameter refers to a file, not
a socket. The socket is shut down for writing, or the socket is con-
nection-oriented and the peer is closed or shut down for reading. In
the latter case, and if the socket is of type SOCK_STREAM, the SIGPIPE
signal is generated to the calling process. The socket is marked non-
blocking, and no space is available for the sendto() function.
RELATED INFORMATION
Functions: recv(2), recvfrom(2), recvmsg(2), send(2), sendmsg(2), shut-
down(2), socket(2), select(2), getsockopt(2), setsockopt(2)
Standards: standards(5) delim off
sendto(2)