Manual Page Result
0
Command: sendmsg | Section: 2 | Source: Digital UNIX | File: sendmsg.2.gz
sendmsg(2) System Calls Manual sendmsg(2)
NAME
sendmsg - Sends a message from a socket using a message structure
SYNOPSIS
#include <sys/socket.h>
ssize_t sendmsg (
int socket, const struct msghdr *message, int flags );
[Digital] The following definition of the sendmsg) function does not
conform to current standards and is supported only for backward compat-
ibility (see standards(5)):
int sendmsg (
int socket, struct msghdr *message, int flags );
STANDARDS
Interfaces documented on this reference page conform to industry stan-
dards as follows:
sendmsg(): XPG4-UNIX
Refer to the standards(5) reference page for more information about in-
dustry standards and associated tags.
PARAMETERS
Specifies the socket descriptor. Points to a msghdr structure, con-
taining pointers to both the destination address for the outgoing mes-
sage and to buffers containing ancillary data. The format of the ad-
dress is determined by the behavior requested for the socket.
[Digital] If the compile-time option _SOCKADDR_LEN is defined
before the <sys/socket.h> header file is included, the msghdr
structure takes 4.4BSD behavior. Otherwise, the default 4.3BSD
msghdr structure is used. In 4.4BSD, the msghdr structure has a
separate msg_flags field for holding flags from the received
message. In addition, the msg_accrights field is generalized
into a msg_control field. See the recvmsg() function for more
information. If _SOCKADDR_LEN is defined, the 4.3BSD msghdr
structure is defined with the name omsghdr. Allows the sender
to control the message transmission. The <sys/socket.h> file
contains the flags values. The flags value to send a call is
formed by a logical OR of one or both of the following values:
Processes out-of-band data on sockets that support out-of-band
data. Sends without using routing tables. (Not recommended,
for debugging purposes only.)
DESCRIPTION
The sendmsg() function sends messages through connected or unconnected
sockets using the msghdr message structure. This minimizes the number
of directly supplied parameters to the function call. The
<sys/socket.h> file contains the msghdr structure and defines the
structure members.
To broadcast on a socket, the application program must first issue a
setsockopt() function using the SO_BROADCAST option to gain broadcast
permissions.
NOTES
[Digital] When compiled in the X/Open UNIX environment, calls to the
sendmsg() function are internally renamed by prepending _E to the func-
tion name. When you are debugging a module that includes the sendmsg()
function and for which _XOPEN_SOURCE_EXTENDED has been defined, use
_Esendmsg to refer to the sendmsg() call. See standards(5) for further
information.
RETURN VALUES
Upon successful completion, the sendmsg() 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 sendmsg() 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. A signal interrupted sendmsg before any data was transmitted.
The sum of the iov_len values overflows an ssize_t. An I/O error oc-
curred while reading from or writing to the file system. Too many sym-
bolic 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 exceeded NAME_MAX charac-
ters, or an entire pathname exceeded PATH_MAX characters. A component
of the pathname does not name an existing file or the pathname is an
empty string. A socket is connection-oriented but is not connected. A
component of the path prefix of the pathname in address is not a di-
rectory. The socket parameter refers to a file, not a socket. The
socket argument is associated with a socket that does not support one
or more of the values set in flags. The socket is shut down for writ-
ing, or the socket is connection-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 nonblocking, and no space is available for the
sendmsg() function.
RELATED INFORMATION
Functions: recv(2), recvfrom(2), recvmsg(2), send(2), sendto(2), shut-
down(2), socket(2), select(2), getsockopt(2), setsockopt(2)
Standards: standards(5) delim off
sendmsg(2)