1SEND(3P)                   POSIX Programmer's Manual                  SEND(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       send - send a message on a socket
13

SYNOPSIS

15       #include <sys/socket.h>
16
17       ssize_t send(int socket, const void *buffer, size_t length, int flags);
18
19

DESCRIPTION

21       The send() function shall initiate transmission of a message  from  the
22       specified  socket to its peer. The send() function shall send a message
23       only when the socket is connected (including when the peer of a connec‐
24       tionless socket has been set via connect()).
25
26       The send() function takes the following arguments:
27
28       socket Specifies the socket file descriptor.
29
30       buffer Points to the buffer containing the message to send.
31
32       length Specifies the length of the message in bytes.
33
34       flags  Specifies the type of message transmission. Values of this argu‐
35              ment are formed by logically OR'ing zero or more of the  follow‐
36              ing flags:
37
38       MSG_EOR
39              Terminates a record (if supported by the protocol).
40
41       MSG_OOB
42              Sends  out-of-band data on sockets that support out-of-band com‐
43              munications.  The significance and semantics of out-of-band data
44              are protocol-specific.
45
46
47
48       The  length  of the message to be sent is specified by the length argu‐
49       ment. If the message is too long to pass through the underlying  proto‐
50       col, send() shall fail and no data shall be transmitted.
51
52       Successful  completion  of a call to send() does not guarantee delivery
53       of the message. A return value of -1  indicates  only  locally-detected
54       errors.
55
56       If  space is not available at the sending socket to hold the message to
57       be transmitted, and the socket file descriptor does not have O_NONBLOCK
58       set,  send()  shall  block  until  space is available.  If space is not
59       available at the sending socket to hold the message to be  transmitted,
60       and  the  socket file descriptor does have O_NONBLOCK set, send() shall
61       fail. The select() and poll() functions can be used to  determine  when
62       it is possible to send more data.
63
64       The  socket  in  use may require the process to have appropriate privi‐
65       leges to use the send() function.
66

RETURN VALUE

68       Upon successful completion, send() shall return  the  number  of  bytes
69       sent.  Otherwise,  -1  shall  be returned and errno set to indicate the
70       error.
71

ERRORS

73       The send() function shall fail if:
74
75       EAGAIN or EWOULDBLOCK
76
77              The socket's  file  descriptor  is  marked  O_NONBLOCK  and  the
78              requested operation would block.
79
80       EBADF  The socket argument is not a valid file descriptor.
81
82       ECONNRESET
83              A connection was forcibly closed by a peer.
84
85       EDESTADDRREQ
86
87              The socket is not connection-mode and no peer address is set.
88
89       EINTR  A signal interrupted send() before any data was transmitted.
90
91       EMSGSIZE
92              The  message  is too large to be sent all at once, as the socket
93              requires.
94
95       ENOTCONN
96              The socket is not connected or otherwise has not  had  the  peer
97              pre-specified.
98
99       ENOTSOCK
100              The socket argument does not refer to a socket.
101
102       EOPNOTSUPP
103              The  socket  argument  is associated with a socket that does not
104              support one or more of the values set in flags.
105
106       EPIPE  The socket is shut down for writing, or the  socket  is  connec‐
107              tion-mode and is no longer connected. In the latter case, and if
108              the socket is of type SOCK_STREAM, the SIGPIPE signal is  gener‐
109              ated to the calling thread.
110
111
112       The send() function may fail if:
113
114       EACCES The calling process does not have the appropriate privileges.
115
116       EIO    An  I/O error occurred while reading from or writing to the file
117              system.
118
119       ENETDOWN
120              The local network interface used to  reach  the  destination  is
121              down.
122
123       ENETUNREACH
124
125              No route to the network is present.
126
127       ENOBUFS
128              Insufficient  resources  were available in the system to perform
129              the operation.
130
131
132       The following sections are informative.
133

EXAMPLES

135       None.
136

APPLICATION USAGE

138       The send() function is equivalent  to  sendto()  with  a  null  pointer
139       dest_len argument, and to write() if no flags are used.
140

RATIONALE

142       None.
143

FUTURE DIRECTIONS

145       None.
146

SEE ALSO

148       connect(),   getsockopt(),   poll(),   recv(),  recvfrom(),  recvmsg(),
149       select(), sendmsg(), sendto(), setsockopt(), shutdown(), socket(),  the
150       Base Definitions volume of IEEE Std 1003.1-2001, <sys/socket.h>
151
153       Portions  of  this text are reprinted and reproduced in electronic form
154       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
155       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
156       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
157       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
158       event of any discrepancy between this version and the original IEEE and
159       The  Open Group Standard, the original IEEE and The Open Group Standard
160       is the referee document. The original Standard can be  obtained  online
161       at http://www.opengroup.org/unix/online.html .
162
163
164
165IEEE/The Open Group                  2003                             SEND(3P)
Impressum