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

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