1 .\" $OpenBSD: send.2,v 1.31 2014/09/09 06:32:37 guenther Exp $
2 .\" $NetBSD: send.2,v 1.6 1996/01/15 01:17:18 thorpej Exp $
4 .\" Copyright (c) 1983, 1991, 1993
5 .\" The Regents of the University of California. All rights reserved.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\" notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\" notice, this list of conditions and the following disclaimer in the
14 .\" documentation and/or other materials provided with the distribution.
15 .\" 3. Neither the name of the University nor the names of its contributors
16 .\" may be used to endorse or promote products derived from this software
17 .\" without specific prior written permission.
19 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 .\" @(#)send.2 8.2 (Berkeley) 2/21/94
33 .Dd $Mdocdate: September 9 2014 $
40 .Nd send a message from a socket
44 .Fn send "int s" "const void *msg" "size_t len" "int flags"
46 .Fn sendto "int s" "const void *msg" "size_t len" "int flags" "const struct sockaddr *to" "socklen_t tolen"
48 .Fn sendmsg "int s" "const struct msghdr *msg" "int flags"
54 are used to transmit a message to another socket.
56 may be used only when the socket is in a
62 may be used at any time.
64 The address of the target is given by
69 The length of the message is given by
71 If the message is too long to pass atomically through the
72 underlying protocol, the error
75 the message is not transmitted.
77 No indication of failure to deliver is implicit in a
79 Locally detected errors are indicated by a return value of \-1.
81 If no messages space is available at the socket to hold
82 the message to be transmitted, then
84 normally blocks, unless the socket has been placed in
85 non-blocking I/O mode.
90 system calls may be used to determine when it is possible to
95 parameter may include one or more of the following:
97 .Bl -tag -width "MSG_DONTROUTEXX" -offset indent -compact
99 bypass routing tables, silently ignored
103 terminate the record (SOCK_SEQPACKET only)
105 process out-of-band data
112 data on sockets that support this notion (e.g.,
114 the underlying protocol must also support
120 for a description of the
124 The call returns the number of characters sent, or \-1
125 if an error occurred.
134 An invalid descriptor was specified.
140 An invalid user space address was specified for a parameter.
142 The socket requires that message be sent atomically,
143 and the size of the message to be sent made this impossible.
145 The socket is marked non-blocking or the
147 flag is set and the requested operation
150 Insufficient resources were available in the system to perform the operation.
154 parameter is invalid.
155 .It Bq Er ECONNREFUSED
156 The destination host rejected the message (or a previous one).
157 This error can only be returned by connected sockets.
159 The peer forcibly closed the connection. This error can only be returned by
161 .It Bq Er EDESTADDRREQ
162 The socket is not connected, and no destination address was specified.
164 The operation was interrupted by a signal before any data was transmitted.
166 The socket is shut down for writing or not longer connected. If the socket is
171 signal is also sent to the calling thread.
178 may return the following error:
189 may return the following errors:
191 .It Bq Er EAFNOSUPPORT
192 Addresses in the specified address family cannot be used with this socket.
194 The socket is already connected, and a destination address was specified.
198 may return the following errors:
212 was less than 0 or larger than
215 The message contains control information utilizing
217 to pass file descriptors, but too many file descriptors
218 are already in-flight.
239 flag is an extension to that specification.
243 function call appeared in