2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group. In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document. The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
25 .\" This notice shall appear on any product containing this material.
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
43 .\" Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
44 .\" Portions Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved.
46 .TH SENDMSG 3XNET "Nov 1, 2003"
48 sendmsg \- send a message on a socket using a message structure
52 \fBcc\fR [ \fIflag\fR ... ] \fIfile\fR ... \fB-lxnet\fR [ \fIlibrary\fR ... ]
53 #include <sys/socket.h>
55 \fBssize_t\fR \fBsendmsg\fR(\fBint\fR \fIsocket\fR, \fBconst struct msghdr *\fR\fImessage\fR, \fBint\fR \fIflags\fR);
61 The function takes the following arguments:
68 Specifies the socket file descriptor.
77 Points to a \fBmsghdr\fR structure, containing both the destination address and
78 the buffers for the outgoing message. The length and format of the address
79 depend on the address family of the socket. The \fBmsg_flags\fR member is
89 Specifies the type of message transmission. The application may specify 0 or
97 Terminates a record (if supported by the protocol)
106 Sends out-of-band data on sockets that support out-of-bound data. The
107 significance and semantics of out-of-band data are protocol-specific.
115 The \fBsendmsg()\fR function sends a message through a connection-mode or
116 connectionless-mode socket. If the socket is connectionless-mode, the message
117 will be sent to the address specified by \fImsghdr\fR. If the socket is
118 connection-mode, the destination address in \fImsghdr\fR is ignored.
121 The \fImsg_iov\fR and \fImsg_iovlen\fR fields of message specify zero or more
122 buffers containing the data to be sent. \fImsg_iov\fR points to an array of
123 \fBiovec\fR structures; \fImsg_iovlen\fR must be set to the dimension of this
124 array. In each \fBiovec\fR structure, the \fIiov_base\fR field specifies a
125 storage area and the \fIiov_len\fR field gives its size in bytes. Some of
126 these sizes can be zero. The data from each storage area indicated by
127 \fImsg_iov\fR is sent in turn.
130 Successful completion of a call to \fBsendmsg()\fR does not guarantee delivery
131 of the message. A return value of \(mi1 indicates only locally-detected errors.
134 If space is not available at the sending socket to hold the message to be
135 transmitted and the socket file descriptor does not have \fBO_NONBLOCK\fR set,
136 \fBsendmsg()\fR function blocks until space is available. If space is not
137 available at the sending socket to hold the message to be transmitted and the
138 socket file descriptor does have \fBO_NONBLOCK\fR set, \fBsendmsg()\fR function
142 If the socket protocol supports broadcast and the specified address is a
143 broadcast address for the socket protocol, \fBsendmsg()\fR will fail if the
144 \fBSO_BROADCAST\fR option is not set for the socket.
147 The socket in use may require the process to have appropriate privileges to use
148 the \fBsendmsg()\fR function.
152 The \fBselect\fR(3C) and \fBpoll\fR(2) functions can be used to determine when
153 it is possible to send more data.
157 Upon successful completion, \fBsendmsg()\fR function returns the number of
158 bytes sent. Otherwise, \(mi1 is returned and \fBerrno\fR is set to indicate
163 The \fBsendmsg()\fR function will fail if:
171 \fB\fBEWOULDBLOCK\fR\fR
174 The socket's file descriptor is marked O_NONBLOCK and the requested operation
181 \fB\fBEAFNOSUPPORT\fR\fR
184 Addresses in the specified address family cannot be used with this socket.
193 The \fIsocket\fR argument is not a valid file descriptor.
199 \fB\fBECONNRESET\fR\fR
202 A connection was forcibly closed by a peer.
211 The \fImessage\fR parameter, or storage pointed to by the \fImsg_name\fR,
212 \fImsg_control\fR or \fImsg_iov\fR fields of the \fImessage\fR parameter, or
213 storage pointed to by the \fBiovec\fR structures pointed to by the
214 \fImsg_iov\fR field can not be accessed.
223 A signal interrupted \fBsendmsg()\fR before any data was transmitted.
232 The sum of the \fBiov_len\fR values overflows an \fBssize_t\fR.
241 The message is to large to be sent all at once (as the socket requires), or the
242 \fBmsg_iovlen\fR member of the \fBmsghdr\fR structure pointed to by
243 \fImessage\fR is less than or equal to 0 or is greater than \fBIOV_MAX\fR.
252 The socket is connection-mode but is not connected.
261 The \fIsocket\fR argument does not refer a socket.
267 \fB\fBEOPNOTSUPP\fR\fR
270 The \fIsocket\fR argument is associated with a socket that does not support one
271 or more of the values set in \fIflags\fR.
280 The socket is shut down for writing, or the socket is connection-mode and is no
281 longer connected. In the latter case, and if the socket is of type SOCK_STREAM,
282 the \fBSIGPIPE\fR signal is generated to the calling thread.
287 If the address family of the socket is \fBAF_UNIX\fR, then \fBsendmsg()\fR will
295 An I/O error occurred while reading from or writing to the file system.
304 Too many symbolic links were encountered in translating the pathname in the
311 \fB\fBENAMETOOLONG\fR\fR
314 A component of a pathname exceeded \fINAME_MAX\fR characters, or an entire
315 pathname exceeded \fIPATH_MAX\fR characters.
324 A component of the pathname does not name an existing file or the pathname is
334 A component of the path prefix of the pathname in the socket address is not a
340 The \fBsendmsg()\fR function may fail if:
347 Search permission is denied for a component of the path prefix; or write access
348 to the named socket is denied.
354 \fB\fBEDESTADDRREQ\fR\fR
357 The socket is not connection-mode and does not have its peer address set, and
358 no destination address was specified.
364 \fB\fBEHOSTUNREACH\fR\fR
367 The destination host cannot be reached (probably because the host is down or a
368 remote router cannot reach it).
377 An I/O error occurred while reading from or writing to the file system.
386 A destination address was specified and the socket is already connected.
395 The local interface used to reach the destination is down.
401 \fB\fBENETUNREACH\fR\fR
404 No route to the network is present.
413 Insufficient resources were available in the system to perform the operation.
422 Insufficient memory was available to fulfill the request.
431 There were insufficient STREAMS resources available for the operation to
437 If the address family of the socket is \fBAF_UNIX\fR, then \fBsendmsg()\fR may
442 \fB\fBENAMETOOLONG\fR\fR
445 Pathname resolution of a symbolic link produced an intermediate result whose
446 length exceeds \fIPATH_MAX\fR.
452 See \fBattributes\fR(5) for descriptions of the following attributes:
460 ATTRIBUTE TYPE ATTRIBUTE VALUE
462 Interface Stability Standard
470 \fBpoll\fR(2) \fBgetsockopt\fR(3XNET), \fBrecv\fR(3XNET),
471 \fBrecvfrom\fR(3XNET), \fBrecvmsg\fR(3XNET), \fBselect\fR(3C),
472 \fBsend\fR(3XNET), \fBsendto\fR(3XNET), \fBsetsockopt\fR(3XNET),
473 \fBshutdown\fR(3XNET), \fBsocket\fR(3XNET), \fBattributes\fR(5),