1send(3XNET) X/Open Networking Services Library Functions send(3XNET)
2
3
4
6 send - send a message on a socket
7
9 cc [ flag ... ] file ... -lxnet [ library ... ]
10 #include <sys/socket.h>
11
12 ssize_t send(int socket, const void *buffer, size_t length, int flags);
13
14
16 socket Specifies the socket file descriptor.
17
18
19 buffer Points to the buffer containing the message to send.
20
21
22 length Specifies the length of the message in bytes.
23
24
25 flags Specifies the type of message transmission. Values of this
26 argument are formed by logically OR'ing zero or more of the
27 following flags:
28
29 MSG_EOR Terminates a record (if supported by the protocol)
30
31
32 MSG_OOB Sends out-of-band data on sockets that support
33 out-of-band communications. The significance and
34 semantics of out-of-band data are protocol-spe‐
35 cific.
36
37
38
40 The send() function initiates transmission of a message from the speci‐
41 fied socket to its peer. The send() function sends a message only when
42 the socket is connected (including when the peer of a connectionless
43 socket has been set via connect(3XNET)).
44
45
46 The length of the message to be sent is specified by the length argu‐
47 ment. If the message is too long to pass through the underlying proto‐
48 col, send() fails and no data is transmitted.
49
50
51 Successful completion of a call to send() does not guarantee delivery
52 of the message. A return value of −1 indicates only locally-detected
53 errors.
54
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() blocks until space is available. If space is not available
59 at the sending socket to hold the message to be transmitted and the
60 socket file descriptor does have O_NONBLOCK set, send() will fail. The
61 select(3C) and poll(2) functions can be used to determine when it is
62 possible to send more data.
63
64
65 The socket in use may require the process to have appropriate privi‐
66 leges to use the send() function.
67
69 The send() function is identical to sendto(3XNET) with a null pointer
70 dest_len argument, and to write() if no flags are used.
71
73 Upon successful completion, send() returns the number of bytes sent.
74 Otherwise, −1 is returned and errno is set to indicate the error.
75
77 The send() function will fail if:
78
79 EAGAIN The socket's file descriptor is marked O_NONBLOCK and
80 EWOULDBLOCK the requested operation would block.
81
82
83 EBADF The socket argument is not a valid file descriptor.
84
85
86 ECONNRESET A connection was forcibly closed by a peer.
87
88
89 EDESTADDRREQ The socket is not connection-mode and no peer address
90 is set.
91
92
93 EFAULT The buffer parameter can not be accessed.
94
95
96 EINTR A signal interrupted send() before any data was trans‐
97 mitted.
98
99
100 EMSGSIZE The message is too large be sent all at once, as the
101 socket requires.
102
103
104 ENOTCONN The socket is not connected or otherwise has not had
105 the peer prespecified.
106
107
108 ENOTSOCK The socket argument does not refer to a socket.
109
110
111 EOPNOTSUPP The socket argument is associated with a socket that
112 does not support one or more of the values set in
113 flags.
114
115
116 EPIPE The socket is shut down for writing, or the socket is
117 connection-mode and is no longer connected. In the lat‐
118 ter case, and if the socket is of type SOCK_STREAM, the
119 SIGPIPE signal is generated to the calling thread.
120
121
122
123 The send() function may fail if:
124
125 EACCES The calling process does not have the appropriate privi‐
126 leges.
127
128
129 EIO An I/O error occurred while reading from or writing to
130 the file system.
131
132
133 ENETDOWN The local interface used to reach the destination is
134 down.
135
136
137 ENETUNREACH No route to the network is present.
138
139
140 ENOBUFS Insufficient resources were available in the system to
141 perform the operation.
142
143
144 ENOSR There were insufficient STREAMS resources available for
145 the operation to complete.
146
147
149 See attributes(5) for descriptions of the following attributes:
150
151
152
153
154 ┌─────────────────────────────┬─────────────────────────────┐
155 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
156 ├─────────────────────────────┼─────────────────────────────┤
157 │Interface Stability │Standard │
158 ├─────────────────────────────┼─────────────────────────────┤
159 │MT-Level │MT-Safe │
160 └─────────────────────────────┴─────────────────────────────┘
161
163 connect(3XNET), getsockopt(3XNET), poll(2), recv(3XNET),
164 recvfrom(3XNET), recvmsg(3XNET), select(3C), sendmsg(3XNET),
165 sendto(3XNET), setsockopt(3XNET), shutdown(3XNET), socket(3XNET),
166 attributes(5), standards(5)
167
168
169
170SunOS 5.11 1 Nov 2003 send(3XNET)