1 .\" Copyright (c) 1983, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\" must display the following acknowledgement:
14 .\" This product includes software developed by the University of
15 .\" California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" From: @(#)send.2 8.2 (Berkeley) 2/21/94
33 .\" $FreeBSD: src/lib/libc/sys/send.2,v 1.10.2.6 2001/12/14 18:34:01 ru Exp $
34 .\" $DragonFly: src/lib/libcr/sys/Attic/send.2,v 1.3 2003/12/08 13:56:36 eirikn Exp $
43 .Nd send a message from a socket
50 .Fn send "int s" "const void *msg" "size_t len" "int flags"
52 .Fn sendto "int s" "const void *msg" "size_t len" "int flags" "const struct sockaddr *to" "socklen_t tolen"
54 .Fn sendmsg "int s" "const struct msghdr *msg" "int flags"
60 are used to transmit a message to another socket.
62 may be used only when the socket is in a
68 may be used at any time.
70 The address of the target is given by
75 The length of the message is given by
77 If the message is too long to pass atomically through the
78 underlying protocol, the error
81 the message is not transmitted.
83 No indication of failure to deliver is implicit in a
85 Locally detected errors are indicated by a return value of -1.
87 If no messages space is available at the socket to hold
88 the message to be transmitted, then
90 normally blocks, unless the socket has been placed in
91 non-blocking I/O mode.
94 call may be used to determine when it is possible to
99 parameter may include one or more of the following:
101 #define MSG_OOB 0x1 /* process out-of-band data */
102 #define MSG_PEEK 0x2 /* peek at incoming message */
103 #define MSG_DONTROUTE 0x4 /* bypass routing, use direct interface */
104 #define MSG_EOR 0x8 /* data completes record */
105 #define MSG_EOF 0x100 /* data completes transaction */
112 data on sockets that support this notion (e.g.\&
114 the underlying protocol must also support
118 is used to indicate a record mark for protocols which support the
121 requests that the sender side of a socket be shut down, and that an
122 appropriate indication be sent at the end of the specified data;
123 this flag is only implemented for
127 protocol family, and is used to implement Transaction
132 is usually used only by diagnostic or routing programs.
136 for a description of the
140 The call returns the number of characters sent, or -1
141 if an error occurred.
150 An invalid descriptor was specified.
152 The destination address is a broadcast address, and
154 has not been set on the socket.
160 An invalid user space address was specified for a parameter.
162 The socket requires that message be sent atomically,
163 and the size of the message to be sent made this impossible.
165 The socket is marked non-blocking and the requested operation
168 The system was unable to allocate an internal buffer.
169 The operation may succeed when buffers become available.
171 The output queue for a network interface was full.
172 This generally indicates that the interface has stopped sending,
173 but may be caused by transient congestion.
174 .It Bq Er EHOSTUNREACH
175 The remote host was unreachable.
176 .It Bq Er ECONNREFUSED
177 The socket received an ICMP destination unreachable message
178 from the last message sent. This typically means that the
179 receiver is not listening on the remote port.
181 The remote host was down.
183 The socket is unable to send anymore data (SS_CANTSENDMORE has
184 been set on the socket). This typically means that the socket
190 doesn't necessarily block until the data has been transferred, it
191 is possible to transfer an open file descriptor across an
198 it before it has actually been sent, the result being that the receiver
199 gets a closed file descriptor. It is left to the application to
200 implement an acknowlegment mechanism to prevent this from happening.
211 function call appeared in