1 <!-- Copyright (C) 2003 Red Hat, Inc. -->
2 <!-- This material may be distributed only subject to the terms -->
3 <!-- and conditions set forth in the Open Publication License, v1.0 -->
4 <!-- or later (the latest version is presently available at -->
5 <!-- http://www.opencontent.org/openpub/). -->
6 <!-- Distribution of the work or derivative of the work in any -->
7 <!-- standard (paper) book form is prohibited unless prior -->
8 <!-- permission is obtained from the copyright holder. -->
13 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
16 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
19 TITLE="eCos Reference Manual"
20 HREF="ecos-ref.html"><LINK
22 TITLE="TCP/IP Library Reference"
23 HREF="tcpip-library-reference.html"><LINK
26 HREF="net-common-tcpip-manpages-select.html"><LINK
29 HREF="net-common-tcpip-manpages-shutdown.html"></HEAD
40 SUMMARY="Header navigation table"
49 >eCos Reference Manual</TH
57 HREF="net-common-tcpip-manpages-select.html"
65 >Chapter 38. TCP/IP Library Reference</TD
71 HREF="net-common-tcpip-manpages-shutdown.html"
85 NAME="NET-COMMON-TCPIP-MANPAGES-SEND">send</H1
94 >SEND(2) System Calls Manual SEND(2)
97 send, sendto, sendmsg - send a message from a socket
100 #include <sys/types.h>
101 #include <sys/socket.h>
104 send(int s, const void *msg, size_t len, int flags);
107 sendto(int s, const void *msg, size_t len, int flags,
108 const struct sockaddr *to, socklen_t tolen);
111 sendmsg(int s, const struct msghdr *msg, int flags);
114 send(), sendto(), and sendmsg() are used to transmit a message to another
115 socket. send() may be used only when the socket is in a connected state,
116 while sendto() and sendmsg() may be used at any time.
118 The address of the target is given by to with tolen specifying its size.
119 The length of the message is given by len. If the message is too long to
120 pass atomically through the underlying protocol, the error EMSGSIZE is
121 returned, and the message is not transmitted.
123 No indication of failure to deliver is implicit in a send(). Locally
124 detected errors are indicated by a return value of -1.
126 If no messages space is available at the socket to hold the message to be
127 transmitted, then send() normally blocks, unless the socket has been
128 placed in non-blocking I/O mode. The select(2) or poll(2) system calls
129 may be used to determine when it is possible to send more data.
131 The flags parameter may include one or more of the following:
133 #define MSG_OOB 0x1 /* process out-of-band data */
134 #define MSG_DONTROUTE 0x4 /* bypass routing, use direct interface */
136 The flag MSG_OOB is used to send ``out-of-band'' data on sockets that
137 support this notion (e.g., SOCK_STREAM); the underlying protocol must
138 also support ``out-of-band'' data. MSG_DONTROUTE is usually used only by
139 diagnostic or routing programs.
141 See recv(2) for a description of the msghdr structure.
144 The call returns the number of characters sent, or -1 if an error
148 send(), sendto(), and sendmsg() fail if:
150 [EBADF] An invalid descriptor was specified.
152 [ENOTSOCK] The argument s is not a socket.
154 [EFAULT] An invalid user space address was specified for a
157 [EMSGSIZE] The socket requires that message be sent atomically,
158 and the size of the message to be sent made this
161 [EAGAIN] The socket is marked non-blocking and the requested
162 operation would block.
164 [ENOBUFS] The system was unable to allocate an internal buffer.
165 The operation may succeed when buffers become avail-
168 [ENOBUFS] The output queue for a network interface was full.
169 This generally indicates that the interface has
170 stopped sending, but may be caused by transient con-
173 [EACCES] The SO_BROADCAST option is not set on the socket, and
174 a broadcast address was given as the destination.
176 [EHOSTUNREACH] The destination address specified an unreachable host.
178 [EINVAL] The flags parameter is invalid.
180 [EHOSTDOWN] The destination address specified a host that is down.
182 [ENETDOWN] The destination address specified a network that is
185 [ECONNREFUSED] The destination host rejected the message (or a previ-
186 ous one). This error can only be returned by con-
189 [ENOPROTOOPT] There was a problem sending the message. This error
190 can only be returned by connected sockets.
192 [EDESTADDRREQ] The socket is not connected, and no destination
193 address was specified.
195 [EISCONN] The socket is already connected, and a destination
196 address was specified.
198 In addition, send() and sendto() may return the following error:
200 [EINVAL] len was larger than SSIZE_MAX.
202 Also, sendmsg() may return the following errors:
204 [EINVAL] The sum of the iov_len values in the msg_iov array
205 overflowed an ssize_t.
207 [EMSGSIZE] The msg_iovlen member of msg was less than 0 or larger
210 [EAFNOSUPPORT] Addresses in the specified address family cannot be
211 used with this socket.
214 fcntl(2), getsockopt(2), poll(2), recv(2), select(2), poll(2), socket(2),
218 The send() function call appeared in 4.2BSD.
220 BSD July 28, 1998 BSD
231 SUMMARY="Footer navigation table"
242 HREF="net-common-tcpip-manpages-select.html"
260 HREF="net-common-tcpip-manpages-shutdown.html"
276 HREF="tcpip-library-reference.html"