~ubuntu-branches/ubuntu/precise/manpages-posix/precise

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved 
.TH "SEND" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" send 
.SH NAME
send \- send a message on a socket
.SH SYNOPSIS
.LP
\fB#include <sys/socket.h>
.br
.sp
ssize_t send(int\fP \fIsocket\fP\fB, const void *\fP\fIbuffer\fP\fB,
size_t\fP \fIlength\fP\fB, int\fP
\fIflags\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
The \fIsend\fP() function shall initiate transmission of a message
from the specified socket to its peer. The \fIsend\fP()
function shall send a message only when the socket is connected (including
when the peer of a connectionless socket has been set
via \fIconnect\fP()).
.LP
The \fIsend\fP() function takes the following arguments:
.TP 7
\fIsocket\fP
Specifies the socket file descriptor.
.TP 7
\fIbuffer\fP
Points to the buffer containing the message to send.
.TP 7
\fIlength\fP
Specifies the length of the message in bytes.
.TP 7
\fIflags\fP
Specifies the type of message transmission. Values of this argument
are formed by logically OR'ing zero or more of the
following flags: 
.TP 7
MSG_EOR
.RS
Terminates a record (if supported by the protocol).
.RE
.TP 7
MSG_OOB
.RS
Sends out-of-band data on sockets that support out-of-band communications.
The significance and semantics of out-of-band data
are protocol-specific.
.RE
.sp
.sp
.LP
The length of the message to be sent is specified by the \fIlength\fP
argument. If the message is too long to pass through the
underlying protocol, \fIsend\fP() shall fail and no data shall be
transmitted.
.LP
Successful completion of a call to \fIsend\fP() does not guarantee
delivery of the message. A return value of -1 indicates only
locally-detected errors.
.LP
If space is not available at the sending socket to hold the message
to be transmitted, and the socket file descriptor does not
have O_NONBLOCK set, \fIsend\fP() shall block 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 O_NONBLOCK set, \fIsend\fP() shall fail. The \fIselect\fP() and
\fIpoll\fP() functions can be used to
determine when it is possible to send more data.
.LP
The socket in use may require the process to have appropriate privileges
to use the \fIsend\fP() function.
.SH RETURN VALUE
.LP
Upon successful completion, \fIsend\fP() shall return the number of
bytes sent. Otherwise, -1 shall be returned and
\fIerrno\fP set to indicate the error.
.SH ERRORS
.LP
The \fIsend\fP() function shall fail if:
.TP 7
.B EAGAIN \fRor\fP EWOULDBLOCK
.sp
The socket's file descriptor is marked O_NONBLOCK and the requested
operation would block.
.TP 7
.B EBADF
The \fIsocket\fP argument is not a valid file descriptor.
.TP 7
.B ECONNRESET
A connection was forcibly closed by a peer.
.TP 7
.B EDESTADDRREQ
.sp
The socket is not connection-mode and no peer address is set.
.TP 7
.B EINTR
A signal interrupted \fIsend\fP() before any data was transmitted.
.TP 7
.B EMSGSIZE
The message is too large to be sent all at once, as the socket requires.
.TP 7
.B ENOTCONN
The socket is not connected or otherwise has not had the peer pre-specified.
.TP 7
.B ENOTSOCK
The \fIsocket\fP argument does not refer to a socket.
.TP 7
.B EOPNOTSUPP
The \fIsocket\fP argument is associated with a socket that does not
support one or more of the values set in
\fIflags\fP.
.TP 7
.B 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 SOCK_STREAM, the SIGPIPE signal is generated
to the calling thread.
.sp
.LP
The \fIsend\fP() function may fail if:
.TP 7
.B EACCES
The calling process does not have the appropriate privileges.
.TP 7
.B EIO
An I/O error occurred while reading from or writing to the file system.
.TP 7
.B ENETDOWN
The local network interface used to reach the destination is down.
.TP 7
.B ENETUNREACH
.sp
No route to the network is present.
.TP 7
.B ENOBUFS
Insufficient resources were available in the system to perform the
operation.
.sp
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
The \fIsend\fP() function is equivalent to \fIsendto\fP() with a null
pointer
\fIdest_len\fP argument, and to \fIwrite\fP() if no flags are used.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIconnect\fP() , \fIgetsockopt\fP() , \fIpoll\fP() , \fIrecv\fP()
, \fIrecvfrom\fP() , \fIrecvmsg\fP() , \fIselect\fP() , \fIsendmsg\fP()
, \fIsendto\fP() , \fIsetsockopt\fP() , \fIshutdown\fP() , \fIsocket\fP()
, the Base Definitions volume of
IEEE\ Std\ 1003.1-2001, \fI<sys/socket.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .