'\" rtp .\" -*- nroff -*- vim: ft=nroff noautoindent nocindent nosmartindent .\" .\" @(#) sendmsg.3.man,v 1.1.2.1 2004/05/16 02:35:35 brian Exp .\" .\" ========================================================================= .\" .\" Copyright (C) 2001-2004 OpenSS7 Corporation .\" .\" All Rights Reserved. .\" .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" .\" ------------------------------------------------------------------------- .\" .\" U.S. GOVERNMENT RESTRICTED RIGHTS. If you are licensing this Software .\" on behalf of the U.S. Government ("Government"), the following .\" provisions apply to you. If the Software is supplied by the Department .\" of Defense ("DoD"), it is classified as "Commercial Computer Software" .\" under paragraph 252.227-7014 of the DoD Supplement to the Federal .\" Acquisition Regulations ("DFARS") (or any successor regulations) and the .\" Government is acquiring only the license rights granted herein (the .\" license rights customarily provided to non-Government users). If the .\" Software is supplied to any unit or agency of the Government other than .\" DoD, it is classified as "Restricted Computer Software" and the .\" Government's rights in the Software are defined in paragraph 52.227-19 .\" of the Federal Acquisition Regulations ("FAR") (or any success .\" regulations) or, in the cases of NASA, in paragraph 18.52.227-86 of the .\" NASA Supplement to the FAR (or any successor regulations). .\" .\" ========================================================================= .\" .\" Commercial licensing and support of this software is available from .\" OpenSS7 Corporation at a fee. See http://www.openss7.com/ .\" .\" ========================================================================= .\" .\" Last Modified 2004/05/16 02:35:35 by brian .\" .\" ========================================================================= .so strxnet.macros .R1 bracket-label "\fR[\fB" "\fR]" "\fR, \fB" no-default-database database strxnet.refs accumulate move-punctuation abbreviate A join-authors ", " ", " " and " et-al " et al" 2 3 abbreviate-label-ranges ".." sort-adjacent-labels .R2 .\" .\" .\" .\" .TH SENDMSG 3 "2004/05/16 02:35:35" "strxnet-0_9_2-4" "Linux Fast-STREAMS Sockets Library" .SH NAME .B sendmsg \- send a message on a socket using a message structure .SH SYNOPSIS .PP .B #include .HP .BI "ssize_t sendmsg(int " socket ", const struct msghdr *" message ", int " flags ); .SH DESCRIPTION .PP The .BR sendmsg () function sends a message through a connection-mode or connectionless-mode socket. If the socket is connectionless-mode, the message will be sent to the address specified by .BR msghdr . If the socket is connection-mode, the destination address in .B msghdr is ignored. .PP The function takes the following arguments: .TP .I socket Specifies the socket file descriptor. .TP .I message Points to a .B msghdr structure, containing both the destination address and the buffers for the outgoing message. The length and format of the address depend on the address family of the socket. The .I msg_flags member is ignored. .TP .I flags Specifies the type of message transmission. The application may specify 0 or the following flag: .RS .TP .B MSG_EOR Terminates a record (if supported by the protocol) .TP .B MSG_OOB Sends out-of-band data on sockets that support out-of-bound data. The significance and semantics of out-of-band data are protocol-specific. .RE .PP The .I msg_iov and .I msg_iovlen fields of message specify zero or more buffers containing the data to be sent. .I msg_iov points to an array of iovec structures; .I msg_iovlen must be set to the dimension of this array. In each iovec structure, the .I iov_base field specifies a storage area and the .I iov_len field gives its size in bytes. Some of these sizes can be zero. The data from each storage area indicated by .I msg_iov is sent in turn. .PP Successful completion of a call to .BR sendmsg () does not guarantee delivery of the message. A return value of -1 indicates only locally-detected errors. .PP If space is not available at the sending socket to hold the message to be transmitted and the socket file descriptor does not have .B O_NONBLOCK set, .BR sendmsg () function blocks until space is available. If space is not available at the sending socket to hold the message to be transmitted and the socket file descriptor does have .B O_NONBLOCK set, .BR sendmsg () function will fail. .PP If the socket protocol supports broadcast and the specified address is a broadcast address for the socket protocol, .BR sendmsg () will fail if the .B SO_BROADCAST option is not set for the socket. .PP The socket in use may require the process to have appropriate privileges to use the .BR sendmsg () function. .SH NOTES .PP The .BR select (2) and .BR poll (2) functions can be used to determine when it is possible to send more data. .SH CAVEATS .PP This system call is implemented as a .B SIOCSOCKSYS IOCTL. See .BR socksys (4) for more information. .SH "RETURN VALUE" .PP Upon successful completion, .BR sendmsg () function returns the number of bytes sent. Otherwise, -1 is returned and errno is set to indicate the error. .SH ERRORS .PP The .BR sendmsg () function will fail if: .TP .RB [ EAGAIN "] or [" EWOULDBLOCK ] The socket's file descriptor is marked .B O_NONBLOCK and the requested operation would block. .TP .RB [ EAFNOSUPPORT ] Addresses in the specified address family cannot be used with this socket. .TP .RB [ EBADF ] The socket argument is not a valid file descriptor. .TP .RB [ ECONNRESET ] A connection was forcibly closed by a peer. .TP .RB [ EFAULT ] The message parameter, or storage pointed to by the .IR msg_name , .I msg_control or .I msg_iov fields of the message parameter, or storage pointed to by the iovec structures pointed to by the .I msg_iov field can not be accessed. .TP .RB [ EINTR ] A signal interrupted .BR sendmsg () before any data was transmitted. .TP .RB [ EINVAL ] The sum of the .I iov_len values overflows an .BR ssize_t . .TP .RB [ EMSGSIZE ] The message is too large to be sent all at once (as the socket requires), or the .I msg_iovlen member of the .B msghdr structure pointed to by message is less than or equal to 0 or is greater than {IOV_MAX}. .TP .RB [ ENOTCONN ] The socket is connection-mode but is not connected. .TP .RB [ ENOTSOCK ] The socket argument does not refer a socket. .TP .RB [ EOPNOTSUPP ] The socket argument is associated with a socket that does not support one or more of the values set in .IR flags . .TP .RB [ EPIPE ] The socket is shut down for writing, or the socket is connection-mode and is no longer connected. In the latter case, and if the socket is of type .BR SOCK_STREAM , the .B SIGPIPE signal is generated to the calling process. .PP If the address family of the socket is .BR AF_UNIX , then .BR sendmsg () will fail if: .TP .RB [ EIO ] An I/O error occurred while reading from or writing to the file system. .TP .RB [ ELOOP ] Too many symbolic links were encountered in translating the pathname in the socket address. .TP .RB [ ENAMETOOLONG ] A component of a pathname exceeded .RI { NAME_MAX } characters, or an entire pathname exceeded .RI { PATH_MAX } characters. .TP .RB [ ENOENT ] A component of the pathname does not name an existing file or the pathname is an empty string. .TP .RB [ ENOTDIR ] A component of the path prefix of the pathname in the socket address is not a directory. .PP The .BR sendmsg () function may fail if: .TP .RB [ EACCES ] Search permission is denied for a component of the path prefix; or write access to the named socket is denied. .TP .RB [ EDESTADDRREQ ] The socket is not connection-mode and does not have its peer address set, and no destination address was specified. .TP .RB [ EHOSTUNREACH ] The destination host cannot be reached (probably because the host is down or a remote router cannot reach it). .TP .RB [ EIO ] An I/O error occurred while reading from or writing to the file system. .TP .RB [ EISCONN ] A destination address was specified and the socket is already connected. .TP .RB [ ENETDOWN ] The local interface used to reach the destination is down. .TP .RB [ ENETUNREACH ] No route to the network is present. .TP .RB [ ENOBUFS ] Insufficient resources were available in the system to perform the operation. .TP .RB [ ENOMEM ] Insufficient memory was available to fulfill the request. .TP .RB [ ENOSR ] There were insufficient .IR STREAMS (4) resources available for the operation to complete. .PP If the address family of the socket is .BR AF_UNIX , then .BR sendmsg () may fail if: .TP .RB [ ENAMETOOLONG ] Pathname resolution of a symbolic link produced an intermediate result whose length exceeds .RI { PATH_MAX }. .SH "SEE ALSO" .PP .BR getsockopt (3), .BR poll (2), .BR recv (3), .BR recvfrom (3), .BR recvmsg (3), .BR select (2), .BR send (3), .BR sendto (3), .BR setsockopt (3), .BR shutdown (3), .BR socket (3), .BR (5). .SH "CONFORMING TO" .PP The Open Group XNS Issue 5.2. .[ xns .] .\" .\" .[ $LIST$ .] .TI