OSDN Git Service

42df753239df982bfedf32411b53debd25dfac91
[linuxjm/LDP_man-pages.git] / po4a / socket / po / socket.pot
1 # SOME DESCRIPTIVE TITLE
2 # Copyright (C) YEAR Free Software Foundation, Inc.
3 # This file is distributed under the same license as the PACKAGE package.
4 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5 #
6 #, fuzzy
7 msgid ""
8 msgstr ""
9 "Project-Id-Version: PACKAGE VERSION\n"
10 "POT-Creation-Date: 2013-03-22 01:06+0900\n"
11 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13 "Language-Team: LANGUAGE <LL@li.org>\n"
14 "Language: \n"
15 "MIME-Version: 1.0\n"
16 "Content-Type: text/plain; charset=CHARSET\n"
17 "Content-Transfer-Encoding: 8bit\n"
18
19 #. type: TH
20 #: build/C/man2/accept.2:41
21 #, no-wrap
22 msgid "ACCEPT"
23 msgstr ""
24
25 #. type: TH
26 #: build/C/man2/accept.2:41
27 #, no-wrap
28 msgid "2010-09-10"
29 msgstr ""
30
31 #. type: TH
32 #: build/C/man2/accept.2:41 build/C/man2/bind.2:68 build/C/man2/connect.2:67 build/C/man2/getsockname.2:40 build/C/man2/getsockopt.2:44 build/C/man2/listen.2:45 build/C/man2/recv.2:41 build/C/man2/recvmmsg.2:31 build/C/man2/select.2:38 build/C/man2/select_tut.2:32 build/C/man2/send.2:40 build/C/man2/sendmmsg.2:28 build/C/man3/sockatmark.3:25 build/C/man2/socket.2:43 build/C/man7/socket.7:48 build/C/man2/socketcall.2:25 build/C/man2/socketpair.2:42
33 #, no-wrap
34 msgid "Linux"
35 msgstr ""
36
37 #. type: TH
38 #: build/C/man2/accept.2:41 build/C/man2/bind.2:68 build/C/man3/bindresvport.3:30 build/C/man2/connect.2:67 build/C/man3/getifaddrs.3:36 build/C/man2/getsockname.2:40 build/C/man2/getsockopt.2:44 build/C/man3/if_nameindex.3:26 build/C/man3/if_nametoindex.3:25 build/C/man2/listen.2:45 build/C/man2/recv.2:41 build/C/man2/recvmmsg.2:31 build/C/man2/select.2:38 build/C/man2/select_tut.2:32 build/C/man2/send.2:40 build/C/man2/sendmmsg.2:28 build/C/man3/sockatmark.3:25 build/C/man2/socket.2:43 build/C/man7/socket.7:48 build/C/man2/socketcall.2:25 build/C/man2/socketpair.2:42
39 #, no-wrap
40 msgid "Linux Programmer's Manual"
41 msgstr ""
42
43 #. type: SH
44 #: build/C/man2/accept.2:42 build/C/man2/bind.2:69 build/C/man3/bindresvport.3:31 build/C/man2/connect.2:68 build/C/man3/getifaddrs.3:37 build/C/man2/getsockname.2:41 build/C/man2/getsockopt.2:45 build/C/man3/if_nameindex.3:27 build/C/man3/if_nametoindex.3:26 build/C/man2/listen.2:46 build/C/man2/recv.2:42 build/C/man2/recvmmsg.2:32 build/C/man2/select.2:39 build/C/man2/select_tut.2:33 build/C/man2/send.2:41 build/C/man2/sendmmsg.2:29 build/C/man3/sockatmark.3:26 build/C/man2/socket.2:44 build/C/man7/socket.7:49 build/C/man2/socketcall.2:26 build/C/man2/socketpair.2:43
45 #, no-wrap
46 msgid "NAME"
47 msgstr ""
48
49 #. type: Plain text
50 #: build/C/man2/accept.2:44
51 msgid "accept, accept4 - accept a connection on a socket"
52 msgstr ""
53
54 #. type: SH
55 #: build/C/man2/accept.2:44 build/C/man2/bind.2:71 build/C/man3/bindresvport.3:33 build/C/man2/connect.2:70 build/C/man3/getifaddrs.3:39 build/C/man2/getsockname.2:43 build/C/man2/getsockopt.2:47 build/C/man3/if_nameindex.3:29 build/C/man3/if_nametoindex.3:29 build/C/man2/listen.2:48 build/C/man2/recv.2:44 build/C/man2/recvmmsg.2:34 build/C/man2/select.2:42 build/C/man2/select_tut.2:36 build/C/man2/send.2:43 build/C/man2/sendmmsg.2:31 build/C/man3/sockatmark.3:28 build/C/man2/socket.2:46 build/C/man7/socket.7:51 build/C/man2/socketcall.2:28 build/C/man2/socketpair.2:45
56 #, no-wrap
57 msgid "SYNOPSIS"
58 msgstr ""
59
60 #. type: Plain text
61 #: build/C/man2/accept.2:48 build/C/man2/bind.2:75
62 #, no-wrap
63 msgid ""
64 "B<#include E<lt>sys/types.hE<gt>>          /* See NOTES */\n"
65 "B<#include E<lt>sys/socket.hE<gt>>\n"
66 msgstr ""
67
68 #. type: Plain text
69 #: build/C/man2/accept.2:50
70 #, no-wrap
71 msgid ""
72 "B<int accept(int >I<sockfd>B<, struct sockaddr *>I<addr>B<, socklen_t "
73 "*>I<addrlen>B<);>\n"
74 msgstr ""
75
76 #. type: Plain text
77 #: build/C/man2/accept.2:53
78 #, no-wrap
79 msgid ""
80 "B<#define _GNU_SOURCE>             /* See feature_test_macros(7) */\n"
81 "B<#include E<lt>sys/socket.hE<gt>>\n"
82 msgstr ""
83
84 #. type: Plain text
85 #: build/C/man2/accept.2:56
86 #, no-wrap
87 msgid ""
88 "B<int accept4(int >I<sockfd>B<, struct sockaddr *>I<addr>B<,>\n"
89 "B<            socklen_t *>I<addrlen>B<, int >I<flags>B<);>\n"
90 msgstr ""
91
92 #. type: SH
93 #: build/C/man2/accept.2:57 build/C/man2/bind.2:79 build/C/man3/bindresvport.3:40 build/C/man2/connect.2:79 build/C/man3/getifaddrs.3:48 build/C/man2/getsockname.2:50 build/C/man2/getsockopt.2:58 build/C/man3/if_nameindex.3:36 build/C/man3/if_nametoindex.3:37 build/C/man2/listen.2:56 build/C/man2/recv.2:59 build/C/man2/recvmmsg.2:44 build/C/man2/select.2:81 build/C/man2/select_tut.2:75 build/C/man2/send.2:58 build/C/man2/sendmmsg.2:40 build/C/man3/sockatmark.3:42 build/C/man2/socket.2:52 build/C/man7/socket.7:55 build/C/man2/socketcall.2:30 build/C/man2/socketpair.2:52
94 #, no-wrap
95 msgid "DESCRIPTION"
96 msgstr ""
97
98 #. type: Plain text
99 #: build/C/man2/accept.2:72
100 msgid ""
101 "The B<accept>()  system call is used with connection-based socket types "
102 "(B<SOCK_STREAM>, B<SOCK_SEQPACKET>).  It extracts the first connection "
103 "request on the queue of pending connections for the listening socket, "
104 "I<sockfd>, creates a new connected socket, and returns a new file descriptor "
105 "referring to that socket.  The newly created socket is not in the listening "
106 "state.  The original socket I<sockfd> is unaffected by this call."
107 msgstr ""
108
109 #. type: Plain text
110 #: build/C/man2/accept.2:81
111 msgid ""
112 "The argument I<sockfd> is a socket that has been created with B<socket>(2), "
113 "bound to a local address with B<bind>(2), and is listening for connections "
114 "after a B<listen>(2)."
115 msgstr ""
116
117 #. type: Plain text
118 #: build/C/man2/accept.2:99
119 msgid ""
120 "The argument I<addr> is a pointer to a I<sockaddr> structure.  This "
121 "structure is filled in with the address of the peer socket, as known to the "
122 "communications layer.  The exact format of the address returned I<addr> is "
123 "determined by the socket's address family (see B<socket>(2)  and the "
124 "respective protocol man pages).  When I<addr> is NULL, nothing is filled in; "
125 "in this case, I<addrlen> is not used, and should also be NULL."
126 msgstr ""
127
128 #. type: Plain text
129 #: build/C/man2/accept.2:107
130 msgid ""
131 "The I<addrlen> argument is a value-result argument: the caller must "
132 "initialize it to contain the size (in bytes) of the structure pointed to by "
133 "I<addr>; on return it will contain the actual size of the peer address."
134 msgstr ""
135
136 #. type: Plain text
137 #: build/C/man2/accept.2:112 build/C/man2/getsockname.2:67
138 msgid ""
139 "The returned address is truncated if the buffer provided is too small; in "
140 "this case, I<addrlen> will return a value greater than was supplied to the "
141 "call."
142 msgstr ""
143
144 #. type: Plain text
145 #: build/C/man2/accept.2:125
146 msgid ""
147 "If no pending connections are present on the queue, and the socket is not "
148 "marked as nonblocking, B<accept>()  blocks the caller until a connection is "
149 "present.  If the socket is marked nonblocking and no pending connections are "
150 "present on the queue, B<accept>()  fails with the error B<EAGAIN> or "
151 "B<EWOULDBLOCK>."
152 msgstr ""
153
154 #. type: Plain text
155 #: build/C/man2/accept.2:139
156 msgid ""
157 "In order to be notified of incoming connections on a socket, you can use "
158 "B<select>(2)  or B<poll>(2).  A readable event will be delivered when a new "
159 "connection is attempted and you may then call B<accept>()  to get a socket "
160 "for that connection.  Alternatively, you can set the socket to deliver "
161 "B<SIGIO> when activity occurs on a socket; see B<socket>(7)  for details."
162 msgstr ""
163
164 #. type: Plain text
165 #: build/C/man2/accept.2:152
166 msgid ""
167 "For certain protocols which require an explicit confirmation, such as "
168 "DECNet, B<accept>()  can be thought of as merely dequeuing the next "
169 "connection request and not implying confirmation.  Confirmation can be "
170 "implied by a normal read or write on the new file descriptor, and rejection "
171 "can be implied by closing the new socket.  Currently only DECNet has these "
172 "semantics on Linux."
173 msgstr ""
174
175 #. type: Plain text
176 #: build/C/man2/accept.2:162
177 msgid ""
178 "If I<flags> is 0, then B<accept4>()  is the same as B<accept>().  The "
179 "following values can be bitwise ORed in I<flags> to obtain different "
180 "behavior:"
181 msgstr ""
182
183 #. type: TP
184 #: build/C/man2/accept.2:162 build/C/man2/socket.2:164
185 #, no-wrap
186 msgid "B<SOCK_NONBLOCK>"
187 msgstr ""
188
189 #. type: Plain text
190 #: build/C/man2/accept.2:170 build/C/man2/socket.2:172
191 msgid ""
192 "Set the B<O_NONBLOCK> file status flag on the new open file description.  "
193 "Using this flag saves extra calls to B<fcntl>(2)  to achieve the same "
194 "result."
195 msgstr ""
196
197 #. type: TP
198 #: build/C/man2/accept.2:170 build/C/man2/socket.2:172
199 #, no-wrap
200 msgid "B<SOCK_CLOEXEC>"
201 msgstr ""
202
203 #. type: Plain text
204 #: build/C/man2/accept.2:180 build/C/man2/socket.2:182
205 msgid ""
206 "Set the close-on-exec (B<FD_CLOEXEC>)  flag on the new file descriptor.  See "
207 "the description of the B<O_CLOEXEC> flag in B<open>(2)  for reasons why this "
208 "may be useful."
209 msgstr ""
210
211 #. type: SH
212 #: build/C/man2/accept.2:180 build/C/man2/bind.2:152 build/C/man3/bindresvport.3:67 build/C/man2/connect.2:127 build/C/man3/getifaddrs.3:142 build/C/man2/getsockname.2:67 build/C/man2/getsockopt.2:131 build/C/man3/if_nameindex.3:71 build/C/man3/if_nametoindex.3:54 build/C/man2/listen.2:82 build/C/man2/recv.2:388 build/C/man2/recvmmsg.2:149 build/C/man2/select.2:289 build/C/man2/select_tut.2:485 build/C/man2/send.2:275 build/C/man2/sendmmsg.2:119 build/C/man3/sockatmark.3:51 build/C/man2/socket.2:314 build/C/man2/socketpair.2:69
213 #, no-wrap
214 msgid "RETURN VALUE"
215 msgstr ""
216
217 #. type: Plain text
218 #: build/C/man2/accept.2:187
219 msgid ""
220 "On success, these system calls return a nonnegative integer that is a "
221 "descriptor for the accepted socket.  On error, -1 is returned, and I<errno> "
222 "is set appropriately."
223 msgstr ""
224
225 #. type: SS
226 #: build/C/man2/accept.2:187
227 #, no-wrap
228 msgid "Error handling"
229 msgstr ""
230
231 #. type: Plain text
232 #: build/C/man2/accept.2:214
233 msgid ""
234 "Linux B<accept>()  (and B<accept4>())  passes already-pending network errors "
235 "on the new socket as an error code from B<accept>().  This behavior differs "
236 "from other BSD socket implementations.  For reliable operation the "
237 "application should detect the network errors defined for the protocol after "
238 "B<accept>()  and treat them like B<EAGAIN> by retrying.  In the case of "
239 "TCP/IP, these are B<ENETDOWN>, B<EPROTO>, B<ENOPROTOOPT>, B<EHOSTDOWN>, "
240 "B<ENONET>, B<EHOSTUNREACH>, B<EOPNOTSUPP>, and B<ENETUNREACH>."
241 msgstr ""
242
243 #. type: SH
244 #: build/C/man2/accept.2:214 build/C/man2/bind.2:157 build/C/man3/bindresvport.3:72 build/C/man2/connect.2:132 build/C/man3/getifaddrs.3:149 build/C/man2/getsockname.2:72 build/C/man2/getsockopt.2:136 build/C/man3/if_nameindex.3:78 build/C/man3/if_nametoindex.3:69 build/C/man2/listen.2:87 build/C/man2/recv.2:393 build/C/man2/recvmmsg.2:157 build/C/man2/select.2:306 build/C/man2/send.2:280 build/C/man2/sendmmsg.2:133 build/C/man3/sockatmark.3:56 build/C/man2/socket.2:319 build/C/man2/socketpair.2:74
245 #, no-wrap
246 msgid "ERRORS"
247 msgstr ""
248
249 #. type: TP
250 #: build/C/man2/accept.2:215 build/C/man2/recv.2:398 build/C/man2/send.2:296
251 #, no-wrap
252 msgid "B<EAGAIN> or B<EWOULDBLOCK>"
253 msgstr ""
254
255 #.  Actually EAGAIN on Linux
256 #. type: Plain text
257 #: build/C/man2/accept.2:223
258 msgid ""
259 "The socket is marked nonblocking and no connections are present to be "
260 "accepted.  POSIX.1-2001 allows either error to be returned for this case, "
261 "and does not require these constants to have the same value, so a portable "
262 "application should check for both possibilities."
263 msgstr ""
264
265 #. type: TP
266 #: build/C/man2/accept.2:223 build/C/man2/bind.2:165 build/C/man2/connect.2:169 build/C/man2/getsockname.2:73 build/C/man2/getsockopt.2:137 build/C/man2/listen.2:91 build/C/man2/recv.2:407 build/C/man2/select.2:307 build/C/man2/send.2:304 build/C/man3/sockatmark.3:57
267 #, no-wrap
268 msgid "B<EBADF>"
269 msgstr ""
270
271 #. type: Plain text
272 #: build/C/man2/accept.2:226
273 msgid "The descriptor is invalid."
274 msgstr ""
275
276 #. type: TP
277 #: build/C/man2/accept.2:226
278 #, no-wrap
279 msgid "B<ECONNABORTED>"
280 msgstr ""
281
282 #. type: Plain text
283 #: build/C/man2/accept.2:229
284 msgid "A connection has been aborted."
285 msgstr ""
286
287 #. type: TP
288 #: build/C/man2/accept.2:229 build/C/man2/bind.2:191 build/C/man2/connect.2:175 build/C/man2/getsockname.2:78 build/C/man2/getsockopt.2:142 build/C/man2/recv.2:416 build/C/man2/send.2:313 build/C/man2/socketpair.2:78
289 #, no-wrap
290 msgid "B<EFAULT>"
291 msgstr ""
292
293 #. type: Plain text
294 #: build/C/man2/accept.2:234
295 msgid "The I<addr> argument is not in a writable part of the user address space."
296 msgstr ""
297
298 #. type: TP
299 #: build/C/man2/accept.2:234 build/C/man2/connect.2:203 build/C/man2/recv.2:420 build/C/man2/select.2:312 build/C/man2/send.2:316
300 #, no-wrap
301 msgid "B<EINTR>"
302 msgstr ""
303
304 #. type: Plain text
305 #: build/C/man2/accept.2:239
306 msgid ""
307 "The system call was interrupted by a signal that was caught before a valid "
308 "connection arrived; see B<signal>(7)."
309 msgstr ""
310
311 #. type: TP
312 #: build/C/man2/accept.2:239 build/C/man2/accept.2:244 build/C/man2/bind.2:169 build/C/man2/bind.2:195 build/C/man2/getsockname.2:84 build/C/man2/getsockopt.2:152 build/C/man2/recv.2:425 build/C/man2/recvmmsg.2:161 build/C/man2/select.2:316 build/C/man2/send.2:320 build/C/man3/sockatmark.3:61 build/C/man2/socket.2:327 build/C/man2/socket.2:330
313 #, no-wrap
314 msgid "B<EINVAL>"
315 msgstr ""
316
317 #. type: Plain text
318 #: build/C/man2/accept.2:244
319 msgid ""
320 "Socket is not listening for connections, or I<addrlen> is invalid (e.g., is "
321 "negative)."
322 msgstr ""
323
324 #. type: Plain text
325 #: build/C/man2/accept.2:249
326 msgid "(B<accept4>())  invalid value in I<flags>."
327 msgstr ""
328
329 #. type: TP
330 #: build/C/man2/accept.2:249 build/C/man2/socket.2:335 build/C/man2/socketpair.2:83
331 #, no-wrap
332 msgid "B<EMFILE>"
333 msgstr ""
334
335 #. type: Plain text
336 #: build/C/man2/accept.2:252
337 msgid "The per-process limit of open file descriptors has been reached."
338 msgstr ""
339
340 #. type: TP
341 #: build/C/man2/accept.2:252 build/C/man2/socket.2:338 build/C/man2/socketpair.2:86
342 #, no-wrap
343 msgid "B<ENFILE>"
344 msgstr ""
345
346 #. type: Plain text
347 #: build/C/man2/accept.2:255 build/C/man2/socket.2:341 build/C/man2/socketpair.2:89
348 msgid "The system limit on the total number of open files has been reached."
349 msgstr ""
350
351 #. type: TP
352 #: build/C/man2/accept.2:255
353 #, no-wrap
354 msgid "B<ENOBUFS>, B<ENOMEM>"
355 msgstr ""
356
357 #. type: Plain text
358 #: build/C/man2/accept.2:260
359 msgid ""
360 "Not enough free memory.  This often means that the memory allocation is "
361 "limited by the socket buffer limits, not by the system memory."
362 msgstr ""
363
364 #. type: TP
365 #: build/C/man2/accept.2:260 build/C/man2/bind.2:174 build/C/man2/connect.2:215 build/C/man2/getsockname.2:92 build/C/man2/getsockopt.2:166 build/C/man2/listen.2:96 build/C/man2/recv.2:440 build/C/man2/send.2:349
366 #, no-wrap
367 msgid "B<ENOTSOCK>"
368 msgstr ""
369
370 #. type: Plain text
371 #: build/C/man2/accept.2:263
372 msgid "The descriptor references a file, not a socket."
373 msgstr ""
374
375 #. type: TP
376 #: build/C/man2/accept.2:263 build/C/man2/listen.2:101 build/C/man2/send.2:354 build/C/man2/socketpair.2:89
377 #, no-wrap
378 msgid "B<EOPNOTSUPP>"
379 msgstr ""
380
381 #. type: Plain text
382 #: build/C/man2/accept.2:267
383 msgid "The referenced socket is not of type B<SOCK_STREAM>."
384 msgstr ""
385
386 #. type: TP
387 #: build/C/man2/accept.2:267
388 #, no-wrap
389 msgid "B<EPROTO>"
390 msgstr ""
391
392 #. type: Plain text
393 #: build/C/man2/accept.2:270
394 msgid "Protocol error."
395 msgstr ""
396
397 #. type: Plain text
398 #: build/C/man2/accept.2:274
399 msgid "In addition, Linux B<accept>()  may fail if:"
400 msgstr ""
401
402 #. type: TP
403 #: build/C/man2/accept.2:274
404 #, no-wrap
405 msgid "B<EPERM>"
406 msgstr ""
407
408 #. type: Plain text
409 #: build/C/man2/accept.2:277
410 msgid "Firewall rules forbid connection."
411 msgstr ""
412
413 #. type: Plain text
414 #: build/C/man2/accept.2:289
415 msgid ""
416 "In addition, network errors for the new socket and as defined for the "
417 "protocol may be returned.  Various Linux kernels can return other errors "
418 "such as B<ENOSR>, B<ESOCKTNOSUPPORT>, B<EPROTONOSUPPORT>, B<ETIMEDOUT>.  The "
419 "value B<ERESTARTSYS> may be seen during a trace."
420 msgstr ""
421
422 #. type: SH
423 #: build/C/man2/accept.2:289 build/C/man3/getifaddrs.3:162 build/C/man3/if_nameindex.3:97 build/C/man2/recvmmsg.2:165 build/C/man2/select.2:325 build/C/man2/sendmmsg.2:145 build/C/man3/sockatmark.3:68 build/C/man7/socket.7:802
424 #, no-wrap
425 msgid "VERSIONS"
426 msgstr ""
427
428 #. type: Plain text
429 #: build/C/man2/accept.2:294
430 msgid ""
431 "The B<accept4>()  system call is available starting with Linux 2.6.28; "
432 "support in glibc is available starting with version 2.10."
433 msgstr ""
434
435 #. type: SH
436 #: build/C/man2/accept.2:294 build/C/man2/bind.2:222 build/C/man3/bindresvport.3:92 build/C/man2/connect.2:225 build/C/man3/getifaddrs.3:170 build/C/man2/getsockname.2:97 build/C/man2/getsockopt.2:171 build/C/man3/if_nameindex.3:104 build/C/man3/if_nametoindex.3:85 build/C/man2/listen.2:106 build/C/man2/recv.2:445 build/C/man2/recvmmsg.2:170 build/C/man2/select.2:331 build/C/man2/send.2:368 build/C/man2/sendmmsg.2:150 build/C/man3/sockatmark.3:71 build/C/man2/socket.2:352 build/C/man2/socketcall.2:42 build/C/man2/socketpair.2:95
437 #, no-wrap
438 msgid "CONFORMING TO"
439 msgstr ""
440
441 #.  The BSD man page documents five possible error returns
442 #.  (EBADF, ENOTSOCK, EOPNOTSUPP, EWOULDBLOCK, EFAULT).
443 #.  POSIX.1-2001 documents errors
444 #.  EAGAIN, EBADF, ECONNABORTED, EINTR, EINVAL, EMFILE,
445 #.  ENFILE, ENOBUFS, ENOMEM, ENOTSOCK, EOPNOTSUPP, EPROTO, EWOULDBLOCK.
446 #.  In addition, SUSv2 documents EFAULT and ENOSR.
447 #. type: Plain text
448 #: build/C/man2/accept.2:306
449 msgid ""
450 "B<accept>(): POSIX.1-2001, SVr4, 4.4BSD, (B<accept>()  first appeared in "
451 "4.2BSD)."
452 msgstr ""
453
454 #. type: Plain text
455 #: build/C/man2/accept.2:309
456 msgid "B<accept4>()  is a nonstandard Linux extension."
457 msgstr ""
458
459 #.  Some testing seems to show that Tru64 5.1 and HP-UX 11 also
460 #.  do not inherit file status flags -- MTK Jun 05
461 #. type: Plain text
462 #: build/C/man2/accept.2:324
463 msgid ""
464 "On Linux, the new socket returned by B<accept>()  does I<not> inherit file "
465 "status flags such as B<O_NONBLOCK> and B<O_ASYNC> from the listening "
466 "socket.  This behavior differs from the canonical BSD sockets "
467 "implementation.  Portable programs should not rely on inheritance or "
468 "noninheritance of file status flags and always explicitly set all required "
469 "flags on the socket returned from B<accept>()."
470 msgstr ""
471
472 #. type: SH
473 #: build/C/man2/accept.2:324 build/C/man2/bind.2:234 build/C/man3/bindresvport.3:95 build/C/man2/connect.2:241 build/C/man3/getifaddrs.3:190 build/C/man2/getsockname.2:103 build/C/man2/getsockopt.2:178 build/C/man2/listen.2:111 build/C/man2/recv.2:455 build/C/man2/select.2:346 build/C/man2/select_tut.2:503 build/C/man2/send.2:382 build/C/man2/sendmmsg.2:153 build/C/man3/sockatmark.3:73 build/C/man2/socket.2:366 build/C/man7/socket.7:816 build/C/man2/socketcall.2:45 build/C/man2/socketpair.2:103
474 #, no-wrap
475 msgid "NOTES"
476 msgstr ""
477
478 #. type: Plain text
479 #: build/C/man2/accept.2:330 build/C/man2/bind.2:240 build/C/man2/connect.2:247 build/C/man2/getsockopt.2:184 build/C/man2/listen.2:137 build/C/man2/socket.2:372 build/C/man2/socketpair.2:124
480 msgid ""
481 "POSIX.1-2001 does not require the inclusion of I<E<lt>sys/types.hE<gt>>, and "
482 "this header file is not required on Linux.  However, some historical (BSD) "
483 "implementations required this header file, and portable applications are "
484 "probably wise to include it."
485 msgstr ""
486
487 #. type: Plain text
488 #: build/C/man2/accept.2:351
489 msgid ""
490 "There may not always be a connection waiting after a B<SIGIO> is delivered "
491 "or B<select>(2)  or B<poll>(2)  return a readability event because the "
492 "connection might have been removed by an asynchronous network error or "
493 "another thread before B<accept>()  is called.  If this happens then the call "
494 "will block waiting for the next connection to arrive.  To ensure that "
495 "B<accept>()  never blocks, the passed socket I<sockfd> needs to have the "
496 "B<O_NONBLOCK> flag set (see B<socket>(7))."
497 msgstr ""
498
499 #. type: SS
500 #: build/C/man2/accept.2:351
501 #, no-wrap
502 msgid "The socklen_t type"
503 msgstr ""
504
505 #. type: Plain text
506 #: build/C/man2/accept.2:361
507 msgid ""
508 "The third argument of B<accept>()  was originally declared as an I<int *> "
509 "(and is that under libc4 and libc5 and on many other systems like 4.x BSD, "
510 "SunOS 4, SGI); a POSIX.1g draft standard wanted to change it into a I<size_t "
511 "*>, and that is what it is for SunOS 5.  Later POSIX drafts have I<socklen_t "
512 "*>, and so do the Single UNIX Specification and glibc2.  Quoting Linus "
513 "Torvalds:"
514 msgstr ""
515
516 #.  .I fails: only italicizes a single line
517 #. type: Plain text
518 #: build/C/man2/accept.2:378
519 msgid ""
520 "\"_Any_ sane library _must_ have \"socklen_t\" be the same size as int.  "
521 "Anything else breaks any BSD socket layer stuff.  POSIX initially I<did> "
522 "make it a size_t, and I (and hopefully others, but obviously not too many) "
523 "complained to them very loudly indeed.  Making it a size_t is completely "
524 "broken, exactly because size_t very seldom is the same size as \"int\" on "
525 "64-bit architectures, for example.  And it I<has> to be the same size as "
526 "\"int\" because that's what the BSD socket interface is.  Anyway, the POSIX "
527 "people eventually got a clue, and created \"socklen_t\".  They shouldn't "
528 "have touched it in the first place, but once they did they felt it had to "
529 "have a named type for some unfathomable reason (probably somebody didn't "
530 "like losing face over having done the original stupid thing, so they "
531 "silently just renamed their blunder).\""
532 msgstr ""
533
534 #. type: SH
535 #: build/C/man2/accept.2:378 build/C/man2/bind.2:254 build/C/man2/connect.2:258 build/C/man3/getifaddrs.3:207 build/C/man3/if_nameindex.3:108 build/C/man2/listen.2:166 build/C/man2/recv.2:490 build/C/man2/recvmmsg.2:173 build/C/man2/select.2:537 build/C/man2/select_tut.2:529 build/C/man2/send.2:419 build/C/man2/sendmmsg.2:168 build/C/man3/sockatmark.3:97 build/C/man2/socket.2:385
536 #, no-wrap
537 msgid "EXAMPLE"
538 msgstr ""
539
540 #. type: Plain text
541 #: build/C/man2/accept.2:381 build/C/man2/listen.2:169
542 msgid "See B<bind>(2)."
543 msgstr ""
544
545 #. type: SH
546 #: build/C/man2/accept.2:381 build/C/man2/bind.2:319 build/C/man3/bindresvport.3:101 build/C/man2/connect.2:263 build/C/man3/getifaddrs.3:290 build/C/man2/getsockname.2:112 build/C/man2/getsockopt.2:202 build/C/man3/if_nameindex.3:146 build/C/man3/if_nametoindex.3:89 build/C/man2/listen.2:169 build/C/man2/recv.2:495 build/C/man2/recvmmsg.2:268 build/C/man2/select.2:574 build/C/man2/select_tut.2:819 build/C/man2/send.2:424 build/C/man2/sendmmsg.2:236 build/C/man3/sockatmark.3:132 build/C/man2/socket.2:390 build/C/man7/socket.7:847 build/C/man2/socketcall.2:53 build/C/man2/socketpair.2:124
547 #, no-wrap
548 msgid "SEE ALSO"
549 msgstr ""
550
551 #. type: Plain text
552 #: build/C/man2/accept.2:388
553 msgid ""
554 "B<bind>(2), B<connect>(2), B<listen>(2), B<select>(2), B<socket>(2), "
555 "B<socket>(7)"
556 msgstr ""
557
558 #. type: SH
559 #: build/C/man2/accept.2:388 build/C/man2/bind.2:332 build/C/man3/bindresvport.3:104 build/C/man2/connect.2:270 build/C/man3/getifaddrs.3:296 build/C/man2/getsockname.2:119 build/C/man2/getsockopt.2:210 build/C/man3/if_nameindex.3:153 build/C/man3/if_nametoindex.3:93 build/C/man2/listen.2:175 build/C/man2/recv.2:506 build/C/man2/recvmmsg.2:275 build/C/man2/select.2:588 build/C/man2/select_tut.2:838 build/C/man2/send.2:439 build/C/man2/sendmmsg.2:241 build/C/man3/sockatmark.3:137 build/C/man2/socket.2:419 build/C/man7/socket.7:859 build/C/man2/socketcall.2:71 build/C/man2/socketpair.2:131
560 #, no-wrap
561 msgid "COLOPHON"
562 msgstr ""
563
564 #. type: Plain text
565 #: build/C/man2/accept.2:395 build/C/man2/bind.2:339 build/C/man3/bindresvport.3:111 build/C/man2/connect.2:277 build/C/man3/getifaddrs.3:303 build/C/man2/getsockname.2:126 build/C/man2/getsockopt.2:217 build/C/man3/if_nameindex.3:160 build/C/man3/if_nametoindex.3:100 build/C/man2/listen.2:182 build/C/man2/recv.2:513 build/C/man2/recvmmsg.2:282 build/C/man2/select.2:595 build/C/man2/select_tut.2:845 build/C/man2/send.2:446 build/C/man2/sendmmsg.2:248 build/C/man3/sockatmark.3:144 build/C/man2/socket.2:426 build/C/man7/socket.7:866 build/C/man2/socketcall.2:78 build/C/man2/socketpair.2:138
566 msgid ""
567 "This page is part of release 3.50 of the Linux I<man-pages> project.  A "
568 "description of the project, and information about reporting bugs, can be "
569 "found at http://www.kernel.org/doc/man-pages/."
570 msgstr ""
571
572 #. type: TH
573 #: build/C/man2/bind.2:68
574 #, no-wrap
575 msgid "BIND"
576 msgstr ""
577
578 #. type: TH
579 #: build/C/man2/bind.2:68
580 #, no-wrap
581 msgid "2007-12-28"
582 msgstr ""
583
584 #. type: Plain text
585 #: build/C/man2/bind.2:71
586 msgid "bind - bind a name to a socket"
587 msgstr ""
588
589 #. type: Plain text
590 #: build/C/man2/bind.2:78
591 #, no-wrap
592 msgid ""
593 "B<int bind(int >I<sockfd>B<, const struct sockaddr *>I<addr>B<,>\n"
594 "B<         socklen_t >I<addrlen>B<);>\n"
595 msgstr ""
596
597 #. type: Plain text
598 #: build/C/man2/bind.2:92
599 msgid ""
600 "When a socket is created with B<socket>(2), it exists in a name space "
601 "(address family) but has no address assigned to it.  B<bind>()  assigns the "
602 "address specified by I<addr> to the socket referred to by the file "
603 "descriptor I<sockfd>.  I<addrlen> specifies the size, in bytes, of the "
604 "address structure pointed to by I<addr>.  Traditionally, this operation is "
605 "called \\(lqassigning a name to a socket\\(rq."
606 msgstr ""
607
608 #. type: Plain text
609 #: build/C/man2/bind.2:99
610 msgid ""
611 "It is normally necessary to assign a local address using B<bind>()  before a "
612 "B<SOCK_STREAM> socket may receive connections (see B<accept>(2))."
613 msgstr ""
614
615 #. type: Plain text
616 #: build/C/man2/bind.2:130
617 msgid ""
618 "The rules used in name binding vary between address families.  Consult the "
619 "manual entries in Section 7 for detailed information.  For B<AF_INET> see "
620 "B<ip>(7), for B<AF_INET6> see B<ipv6>(7), for B<AF_UNIX> see B<unix>(7), for "
621 "B<AF_APPLETALK> see B<ddp>(7), for B<AF_PACKET> see B<packet>(7), for "
622 "B<AF_X25> see B<x25>(7)  and for B<AF_NETLINK> see B<netlink>(7)."
623 msgstr ""
624
625 #. type: Plain text
626 #: build/C/man2/bind.2:137
627 msgid ""
628 "The actual structure passed for the I<addr> argument will depend on the "
629 "address family.  The I<sockaddr> structure is defined as something like:"
630 msgstr ""
631
632 #. type: Plain text
633 #: build/C/man2/bind.2:144
634 #, no-wrap
635 msgid ""
636 "struct sockaddr {\n"
637 "    sa_family_t sa_family;\n"
638 "    char        sa_data[14];\n"
639 "}\n"
640 msgstr ""
641
642 #. type: Plain text
643 #: build/C/man2/bind.2:152
644 msgid ""
645 "The only purpose of this structure is to cast the structure pointer passed "
646 "in I<addr> in order to avoid compiler warnings.  See EXAMPLE below."
647 msgstr ""
648
649 #. type: Plain text
650 #: build/C/man2/bind.2:157 build/C/man2/getsockname.2:72 build/C/man2/getsockopt.2:136 build/C/man2/listen.2:87 build/C/man2/socketpair.2:74
651 msgid ""
652 "On success, zero is returned.  On error, -1 is returned, and I<errno> is set "
653 "appropriately."
654 msgstr ""
655
656 #. type: TP
657 #: build/C/man2/bind.2:158 build/C/man2/bind.2:182 build/C/man3/bindresvport.3:77 build/C/man2/connect.2:135 build/C/man2/send.2:285 build/C/man2/socket.2:320
658 #, no-wrap
659 msgid "B<EACCES>"
660 msgstr ""
661
662 #.  e.g., privileged port in AF_INET domain
663 #. type: Plain text
664 #: build/C/man2/bind.2:162
665 msgid "The address is protected, and the user is not the superuser."
666 msgstr ""
667
668 #. type: TP
669 #: build/C/man2/bind.2:162 build/C/man3/bindresvport.3:82 build/C/man2/connect.2:148 build/C/man2/listen.2:88
670 #, no-wrap
671 msgid "B<EADDRINUSE>"
672 msgstr ""
673
674 #. type: Plain text
675 #: build/C/man2/bind.2:165
676 msgid "The given address is already in use."
677 msgstr ""
678
679 #. type: Plain text
680 #: build/C/man2/bind.2:169
681 msgid "I<sockfd> is not a valid descriptor."
682 msgstr ""
683
684 #.  This may change in the future: see
685 #.  .I linux/unix/sock.c for details.
686 #. type: Plain text
687 #: build/C/man2/bind.2:174
688 msgid "The socket is already bound to an address."
689 msgstr ""
690
691 #. type: Plain text
692 #: build/C/man2/bind.2:178
693 msgid "I<sockfd> is a descriptor for a file, not a socket."
694 msgstr ""
695
696 #. type: Plain text
697 #: build/C/man2/bind.2:182
698 msgid "The following errors are specific to UNIX domain (B<AF_UNIX>)  sockets:"
699 msgstr ""
700
701 #. type: Plain text
702 #: build/C/man2/bind.2:187
703 msgid ""
704 "Search permission is denied on a component of the path prefix.  (See also "
705 "B<path_resolution>(7).)"
706 msgstr ""
707
708 #. type: TP
709 #: build/C/man2/bind.2:187
710 #, no-wrap
711 msgid "B<EADDRNOTAVAIL>"
712 msgstr ""
713
714 #. type: Plain text
715 #: build/C/man2/bind.2:191
716 msgid ""
717 "A nonexistent interface was requested or the requested address was not "
718 "local."
719 msgstr ""
720
721 #. type: Plain text
722 #: build/C/man2/bind.2:195
723 msgid "I<addr> points outside the user's accessible address space."
724 msgstr ""
725
726 #. type: Plain text
727 #: build/C/man2/bind.2:202
728 msgid "The I<addrlen> is wrong, or the socket was not in the B<AF_UNIX> family."
729 msgstr ""
730
731 #. type: TP
732 #: build/C/man2/bind.2:202
733 #, no-wrap
734 msgid "B<ELOOP>"
735 msgstr ""
736
737 #. type: Plain text
738 #: build/C/man2/bind.2:206
739 msgid "Too many symbolic links were encountered in resolving I<addr>."
740 msgstr ""
741
742 #. type: TP
743 #: build/C/man2/bind.2:206
744 #, no-wrap
745 msgid "B<ENAMETOOLONG>"
746 msgstr ""
747
748 #. type: Plain text
749 #: build/C/man2/bind.2:210
750 msgid "I<addr> is too long."
751 msgstr ""
752
753 #. type: TP
754 #: build/C/man2/bind.2:210
755 #, no-wrap
756 msgid "B<ENOENT>"
757 msgstr ""
758
759 #. type: Plain text
760 #: build/C/man2/bind.2:213
761 msgid "The file does not exist."
762 msgstr ""
763
764 #. type: TP
765 #: build/C/man2/bind.2:213 build/C/man2/recv.2:429 build/C/man2/select.2:322 build/C/man2/send.2:343
766 #, no-wrap
767 msgid "B<ENOMEM>"
768 msgstr ""
769
770 #. type: Plain text
771 #: build/C/man2/bind.2:216
772 msgid "Insufficient kernel memory was available."
773 msgstr ""
774
775 #. type: TP
776 #: build/C/man2/bind.2:216
777 #, no-wrap
778 msgid "B<ENOTDIR>"
779 msgstr ""
780
781 #. type: Plain text
782 #: build/C/man2/bind.2:219
783 msgid "A component of the path prefix is not a directory."
784 msgstr ""
785
786 #. type: TP
787 #: build/C/man2/bind.2:219
788 #, no-wrap
789 msgid "B<EROFS>"
790 msgstr ""
791
792 #. type: Plain text
793 #: build/C/man2/bind.2:222
794 msgid "The socket inode would reside on a read-only file system."
795 msgstr ""
796
797 #.  SVr4 documents an additional
798 #.  .B ENOSR
799 #.  general error condition, and
800 #.  additional
801 #.  .B EIO
802 #.  and
803 #.  .B EISDIR
804 #.  UNIX-domain error conditions.
805 #. type: Plain text
806 #: build/C/man2/bind.2:234
807 msgid "SVr4, 4.4BSD, POSIX.1-2001 (B<bind>()  first appeared in 4.2BSD)."
808 msgstr ""
809
810 #. type: Plain text
811 #: build/C/man2/bind.2:251
812 msgid ""
813 "The third argument of B<bind>()  is in reality an I<int> (and this is what "
814 "4.x BSD and libc4 and libc5 have).  Some POSIX confusion resulted in the "
815 "present I<socklen_t>, also used by glibc.  See also B<accept>(2)."
816 msgstr ""
817
818 #. type: SH
819 #: build/C/man2/bind.2:251 build/C/man2/getsockopt.2:199 build/C/man2/select.2:474 build/C/man2/send.2:414 build/C/man3/sockatmark.3:93 build/C/man7/socket.7:834
820 #, no-wrap
821 msgid "BUGS"
822 msgstr ""
823
824 #.  FIXME What *are* transparent proxy options?
825 #. type: Plain text
826 #: build/C/man2/bind.2:254
827 msgid "The transparent proxy options are not described."
828 msgstr ""
829
830 #. type: Plain text
831 #: build/C/man2/bind.2:259
832 msgid ""
833 "An example of the use of B<bind>()  with Internet domain sockets can be "
834 "found in B<getaddrinfo>(3)."
835 msgstr ""
836
837 #.  listen.7 refers to this example.
838 #.  accept.7 refers to this example.
839 #.  unix.7 refers to this example.
840 #. type: Plain text
841 #: build/C/man2/bind.2:266
842 msgid ""
843 "The following example shows how to bind a stream socket in the UNIX "
844 "(B<AF_UNIX>)  domain, and accept connections:"
845 msgstr ""
846
847 #. type: Plain text
848 #: build/C/man2/bind.2:273
849 #, no-wrap
850 msgid ""
851 "#include E<lt>sys/socket.hE<gt>\n"
852 "#include E<lt>sys/un.hE<gt>\n"
853 "#include E<lt>stdlib.hE<gt>\n"
854 "#include E<lt>stdio.hE<gt>\n"
855 "#include E<lt>string.hE<gt>\n"
856 msgstr ""
857
858 #. type: Plain text
859 #: build/C/man2/bind.2:276
860 #, no-wrap
861 msgid ""
862 "#define MY_SOCK_PATH \"/somepath\"\n"
863 "#define LISTEN_BACKLOG 50\n"
864 msgstr ""
865
866 #. type: Plain text
867 #: build/C/man2/bind.2:279
868 #, no-wrap
869 msgid ""
870 "#define handle_error(msg) \\e\n"
871 "    do { perror(msg); exit(EXIT_FAILURE); } while (0)\n"
872 msgstr ""
873
874 #. type: Plain text
875 #: build/C/man2/bind.2:286
876 #, no-wrap
877 msgid ""
878 "int\n"
879 "main(int argc, char *argv[])\n"
880 "{\n"
881 "    int sfd, cfd;\n"
882 "    struct sockaddr_un my_addr, peer_addr;\n"
883 "    socklen_t peer_addr_size;\n"
884 msgstr ""
885
886 #. type: Plain text
887 #: build/C/man2/bind.2:290
888 #, no-wrap
889 msgid ""
890 "    sfd = socket(AF_UNIX, SOCK_STREAM, 0);\n"
891 "    if (sfd == -1)\n"
892 "        handle_error(\"socket\");\n"
893 msgstr ""
894
895 #. type: Plain text
896 #: build/C/man2/bind.2:296
897 #, no-wrap
898 msgid ""
899 "    memset(&my_addr, 0, sizeof(struct sockaddr_un));\n"
900 "                        /* Clear structure */\n"
901 "    my_addr.sun_family = AF_UNIX;\n"
902 "    strncpy(my_addr.sun_path, MY_SOCK_PATH,\n"
903 "            sizeof(my_addr.sun_path) - 1);\n"
904 msgstr ""
905
906 #. type: Plain text
907 #: build/C/man2/bind.2:300
908 #, no-wrap
909 msgid ""
910 "    if (bind(sfd, (struct sockaddr *) &my_addr,\n"
911 "            sizeof(struct sockaddr_un)) == -1)\n"
912 "        handle_error(\"bind\");\n"
913 msgstr ""
914
915 #. type: Plain text
916 #: build/C/man2/bind.2:303
917 #, no-wrap
918 msgid ""
919 "    if (listen(sfd, LISTEN_BACKLOG) == -1)\n"
920 "        handle_error(\"listen\");\n"
921 msgstr ""
922
923 #. type: Plain text
924 #: build/C/man2/bind.2:306
925 #, no-wrap
926 msgid ""
927 "    /* Now we can accept incoming connections one\n"
928 "       at a time using accept(2) */\n"
929 msgstr ""
930
931 #. type: Plain text
932 #: build/C/man2/bind.2:312
933 #, no-wrap
934 msgid ""
935 "    peer_addr_size = sizeof(struct sockaddr_un);\n"
936 "    cfd = accept(sfd, (struct sockaddr *) &peer_addr,\n"
937 "                 &peer_addr_size);\n"
938 "    if (cfd == -1)\n"
939 "        handle_error(\"accept\");\n"
940 msgstr ""
941
942 #. type: Plain text
943 #: build/C/man2/bind.2:314
944 #, no-wrap
945 msgid "    /* Code to deal with incoming connection(s)... */\n"
946 msgstr ""
947
948 #. type: Plain text
949 #: build/C/man2/bind.2:318
950 #, no-wrap
951 msgid ""
952 "    /* When no longer required, the socket pathname, MY_SOCK_PATH\n"
953 "       should be deleted using unlink(2) or remove(3) */\n"
954 "}\n"
955 msgstr ""
956
957 #. type: Plain text
958 #: build/C/man2/bind.2:332
959 msgid ""
960 "B<accept>(2), B<connect>(2), B<getsockname>(2), B<listen>(2), B<socket>(2), "
961 "B<getaddrinfo>(3), B<getifaddrs>(3), B<ip>(7), B<ipv6>(7), "
962 "B<path_resolution>(7), B<socket>(7), B<unix>(7)"
963 msgstr ""
964
965 #. type: TH
966 #: build/C/man3/bindresvport.3:30
967 #, no-wrap
968 msgid "BINDRESVPORT"
969 msgstr ""
970
971 #. type: TH
972 #: build/C/man3/bindresvport.3:30 build/C/man2/connect.2:67 build/C/man2/getsockname.2:40 build/C/man2/getsockopt.2:44 build/C/man3/sockatmark.3:25
973 #, no-wrap
974 msgid "2008-12-03"
975 msgstr ""
976
977 #. type: Plain text
978 #: build/C/man3/bindresvport.3:33
979 msgid "bindresvport - bind a socket to a privileged IP port"
980 msgstr ""
981
982 #. type: Plain text
983 #: build/C/man3/bindresvport.3:37
984 #, no-wrap
985 msgid ""
986 "B<#include E<lt>sys/types.hE<gt>>\n"
987 "B<#include E<lt>netinet/in.hE<gt>>\n"
988 msgstr ""
989
990 #. type: Plain text
991 #: build/C/man3/bindresvport.3:39
992 #, no-wrap
993 msgid "B<int bindresvport(int >I<sockfd>B<, struct sockaddr_in *>I<sin>B<);>\n"
994 msgstr ""
995
996 #.  Glibc actually starts searching with a port # in the range 600 to 1023
997 #. type: Plain text
998 #: build/C/man3/bindresvport.3:46
999 msgid ""
1000 "B<bindresvport>()  is used to bind a socket descriptor to a privileged "
1001 "anonymous IP port, that is, a port number arbitrarily selected from the "
1002 "range 512 to 1023."
1003 msgstr ""
1004
1005 #. type: Plain text
1006 #: build/C/man3/bindresvport.3:56
1007 msgid ""
1008 "If the B<bind>(2)  performed by B<bindresvport>()  is successful, and I<sin> "
1009 "is not NULL, then I<sin-E<gt>sin_port> returns the port number actually "
1010 "allocated."
1011 msgstr ""
1012
1013 #. type: Plain text
1014 #: build/C/man3/bindresvport.3:67
1015 msgid ""
1016 "I<sin> can be NULL, in which case I<sin-E<gt>sin_family> is implicitly taken "
1017 "to be B<AF_INET>.  However, in this case, B<bindresvport>()  has no way to "
1018 "return the port number actually allocated.  (This information can later be "
1019 "obtained using B<getsockname>(2).)"
1020 msgstr ""
1021
1022 #. type: Plain text
1023 #: build/C/man3/bindresvport.3:72
1024 msgid ""
1025 "B<bindresvport>()  returns 0 on success; otherwise -1 is returned and "
1026 "I<errno> set to indicate the cause of the error."
1027 msgstr ""
1028
1029 #. type: Plain text
1030 #: build/C/man3/bindresvport.3:77
1031 msgid ""
1032 "B<bindresvport>()  can fail for any of the same reasons as B<bind>(2).  In "
1033 "addition, the following errors may occur:"
1034 msgstr ""
1035
1036 #. type: Plain text
1037 #: build/C/man3/bindresvport.3:82
1038 msgid ""
1039 "The caller did not have superuser privilege (to be precise: the "
1040 "B<CAP_NET_BIND_SERVICE> capability is required)."
1041 msgstr ""
1042
1043 #. type: Plain text
1044 #: build/C/man3/bindresvport.3:85
1045 msgid "All privileged ports are in use."
1046 msgstr ""
1047
1048 #. type: TP
1049 #: build/C/man3/bindresvport.3:85
1050 #, no-wrap
1051 msgid "B<EAFNOSUPPORT> (B<EPFNOSUPPORT> in glibc 2.7 and earlier)"
1052 msgstr ""
1053
1054 #. type: Plain text
1055 #: build/C/man3/bindresvport.3:92
1056 msgid "I<sin> is not NULL and I<sin-E<gt>sin_family> is not B<AF_INET>."
1057 msgstr ""
1058
1059 #. type: Plain text
1060 #: build/C/man3/bindresvport.3:95
1061 msgid "Not in POSIX.1-2001.  Present on the BSDs, Solaris, and many other systems."
1062 msgstr ""
1063
1064 #. type: Plain text
1065 #: build/C/man3/bindresvport.3:101
1066 msgid ""
1067 "Unlike some B<bindresvport>()  implementations, the glibc implementation "
1068 "ignores any value that the caller supplies in I<sin-E<gt>sin_port>."
1069 msgstr ""
1070
1071 #. type: Plain text
1072 #: build/C/man3/bindresvport.3:104
1073 msgid "B<bind>(2), B<getsockname>(2)"
1074 msgstr ""
1075
1076 #. type: TH
1077 #: build/C/man2/connect.2:67
1078 #, no-wrap
1079 msgid "CONNECT"
1080 msgstr ""
1081
1082 #. type: Plain text
1083 #: build/C/man2/connect.2:70
1084 msgid "connect - initiate a connection on a socket"
1085 msgstr ""
1086
1087 #. type: Plain text
1088 #: build/C/man2/connect.2:73 build/C/man2/getsockopt.2:50 build/C/man2/listen.2:51
1089 #, no-wrap
1090 msgid "B<#include E<lt>sys/types.hE<gt>>          /* See NOTES */\n"
1091 msgstr ""
1092
1093 #. type: Plain text
1094 #: build/C/man2/connect.2:75 build/C/man2/getsockname.2:46 build/C/man2/getsockopt.2:52 build/C/man2/listen.2:53 build/C/man2/recv.2:51
1095 #, no-wrap
1096 msgid "B<#include E<lt>sys/socket.hE<gt>>\n"
1097 msgstr ""
1098
1099 #. type: Plain text
1100 #: build/C/man2/connect.2:78
1101 #, no-wrap
1102 msgid ""
1103 "B<int connect(int >I<sockfd>B<, const struct sockaddr *>I<addr>B<,>\n"
1104 "B<            socklen_t >I<addrlen>B<);>\n"
1105 msgstr ""
1106
1107 #. type: Plain text
1108 #: build/C/man2/connect.2:97
1109 msgid ""
1110 "The B<connect>()  system call connects the socket referred to by the file "
1111 "descriptor I<sockfd> to the address specified by I<addr>.  The I<addrlen> "
1112 "argument specifies the size of I<addr>.  The format of the address in "
1113 "I<addr> is determined by the address space of the socket I<sockfd>; see "
1114 "B<socket>(2)  for further details."
1115 msgstr ""
1116
1117 #. type: Plain text
1118 #: build/C/man2/connect.2:113
1119 msgid ""
1120 "If the socket I<sockfd> is of type B<SOCK_DGRAM> then I<addr> is the address "
1121 "to which datagrams are sent by default, and the only address from which "
1122 "datagrams are received.  If the socket is of type B<SOCK_STREAM> or "
1123 "B<SOCK_SEQPACKET>, this call attempts to make a connection to the socket "
1124 "that is bound to the address specified by I<addr>."
1125 msgstr ""
1126
1127 #. type: Plain text
1128 #: build/C/man2/connect.2:127
1129 msgid ""
1130 "Generally, connection-based protocol sockets may successfully B<connect>()  "
1131 "only once; connectionless protocol sockets may use B<connect>()  multiple "
1132 "times to change their association.  Connectionless sockets may dissolve the "
1133 "association by connecting to an address with the I<sa_family> member of "
1134 "I<sockaddr> set to B<AF_UNSPEC> (supported on Linux since kernel 2.2)."
1135 msgstr ""
1136
1137 #. type: Plain text
1138 #: build/C/man2/connect.2:132
1139 msgid ""
1140 "If the connection or binding succeeds, zero is returned.  On error, -1 is "
1141 "returned, and I<errno> is set appropriately."
1142 msgstr ""
1143
1144 #. type: Plain text
1145 #: build/C/man2/connect.2:135
1146 msgid ""
1147 "The following are general socket errors only.  There may be other "
1148 "domain-specific error codes."
1149 msgstr ""
1150
1151 #. type: Plain text
1152 #: build/C/man2/connect.2:143
1153 msgid ""
1154 "For UNIX domain sockets, which are identified by pathname: Write permission "
1155 "is denied on the socket file, or search permission is denied for one of the "
1156 "directories in the path prefix.  (See also B<path_resolution>(7).)"
1157 msgstr ""
1158
1159 #. type: TP
1160 #: build/C/man2/connect.2:143
1161 #, no-wrap
1162 msgid "B<EACCES>, B<EPERM>"
1163 msgstr ""
1164
1165 #. type: Plain text
1166 #: build/C/man2/connect.2:148
1167 msgid ""
1168 "The user tried to connect to a broadcast address without having the socket "
1169 "broadcast flag enabled or the connection request failed because of a local "
1170 "firewall rule."
1171 msgstr ""
1172
1173 #. type: Plain text
1174 #: build/C/man2/connect.2:151
1175 msgid "Local address is already in use."
1176 msgstr ""
1177
1178 #. type: TP
1179 #: build/C/man2/connect.2:151 build/C/man2/socket.2:324 build/C/man2/socketpair.2:75
1180 #, no-wrap
1181 msgid "B<EAFNOSUPPORT>"
1182 msgstr ""
1183
1184 #. type: Plain text
1185 #: build/C/man2/connect.2:156
1186 msgid ""
1187 "The passed address didn't have the correct address family in its "
1188 "I<sa_family> field."
1189 msgstr ""
1190
1191 #. type: TP
1192 #: build/C/man2/connect.2:156
1193 #, no-wrap
1194 msgid "B<EAGAIN>"
1195 msgstr ""
1196
1197 #. type: Plain text
1198 #: build/C/man2/connect.2:165
1199 msgid ""
1200 "No more free local ports or insufficient entries in the routing cache.  For "
1201 "B<AF_INET> see the description of I</proc/sys/net/ipv4/ip_local_port_range> "
1202 "B<ip>(7)  for information on how to increase the number of local ports."
1203 msgstr ""
1204
1205 #. type: TP
1206 #: build/C/man2/connect.2:165
1207 #, no-wrap
1208 msgid "B<EALREADY>"
1209 msgstr ""
1210
1211 #. type: Plain text
1212 #: build/C/man2/connect.2:169
1213 msgid ""
1214 "The socket is nonblocking and a previous connection attempt has not yet been "
1215 "completed."
1216 msgstr ""
1217
1218 #. type: Plain text
1219 #: build/C/man2/connect.2:172
1220 msgid "The file descriptor is not a valid index in the descriptor table."
1221 msgstr ""
1222
1223 #. type: TP
1224 #: build/C/man2/connect.2:172 build/C/man2/recv.2:412
1225 #, no-wrap
1226 msgid "B<ECONNREFUSED>"
1227 msgstr ""
1228
1229 #. type: Plain text
1230 #: build/C/man2/connect.2:175
1231 msgid "No-one listening on the remote address."
1232 msgstr ""
1233
1234 #. type: Plain text
1235 #: build/C/man2/connect.2:178
1236 msgid "The socket structure address is outside the user's address space."
1237 msgstr ""
1238
1239 #. type: TP
1240 #: build/C/man2/connect.2:178
1241 #, no-wrap
1242 msgid "B<EINPROGRESS>"
1243 msgstr ""
1244
1245 #. type: Plain text
1246 #: build/C/man2/connect.2:203
1247 msgid ""
1248 "The socket is nonblocking and the connection cannot be completed "
1249 "immediately.  It is possible to B<select>(2)  or B<poll>(2)  for completion "
1250 "by selecting the socket for writing.  After B<select>(2)  indicates "
1251 "writability, use B<getsockopt>(2)  to read the B<SO_ERROR> option at level "
1252 "B<SOL_SOCKET> to determine whether B<connect>()  completed successfully "
1253 "(B<SO_ERROR> is zero) or unsuccessfully (B<SO_ERROR> is one of the usual "
1254 "error codes listed here, explaining the reason for the failure)."
1255 msgstr ""
1256
1257 #.  For TCP, the connection will complete asynchronously.
1258 #.  See http://lkml.org/lkml/2005/7/12/254
1259 #. type: Plain text
1260 #: build/C/man2/connect.2:209
1261 msgid ""
1262 "The system call was interrupted by a signal that was caught; see "
1263 "B<signal>(7)."
1264 msgstr ""
1265
1266 #. type: TP
1267 #: build/C/man2/connect.2:209 build/C/man2/send.2:323
1268 #, no-wrap
1269 msgid "B<EISCONN>"
1270 msgstr ""
1271
1272 #. type: Plain text
1273 #: build/C/man2/connect.2:212
1274 msgid "The socket is already connected."
1275 msgstr ""
1276
1277 #. type: TP
1278 #: build/C/man2/connect.2:212
1279 #, no-wrap
1280 msgid "B<ENETUNREACH>"
1281 msgstr ""
1282
1283 #. type: Plain text
1284 #: build/C/man2/connect.2:215
1285 msgid "Network is unreachable."
1286 msgstr ""
1287
1288 #. type: Plain text
1289 #: build/C/man2/connect.2:218
1290 msgid "The file descriptor is not associated with a socket."
1291 msgstr ""
1292
1293 #. type: TP
1294 #: build/C/man2/connect.2:218
1295 #, no-wrap
1296 msgid "B<ETIMEDOUT>"
1297 msgstr ""
1298
1299 #. type: Plain text
1300 #: build/C/man2/connect.2:225
1301 msgid ""
1302 "Timeout while attempting connection.  The server may be too busy to accept "
1303 "new connections.  Note that for IP sockets the timeout may be very long when "
1304 "syncookies are enabled on the server."
1305 msgstr ""
1306
1307 #.  SVr4 documents the additional
1308 #.  general error codes
1309 #.  .BR EADDRNOTAVAIL ,
1310 #.  .BR EINVAL ,
1311 #.  .BR EAFNOSUPPORT ,
1312 #.  .BR EALREADY ,
1313 #.  .BR EINTR ,
1314 #.  .BR EPROTOTYPE ,
1315 #.  and
1316 #.  .BR ENOSR .
1317 #.  It also
1318 #.  documents many additional error conditions not described here.
1319 #. type: Plain text
1320 #: build/C/man2/connect.2:241
1321 msgid ""
1322 "SVr4, 4.4BSD, (the B<connect>()  function first appeared in 4.2BSD), "
1323 "POSIX.1-2001."
1324 msgstr ""
1325
1326 #. type: Plain text
1327 #: build/C/man2/connect.2:258
1328 msgid ""
1329 "The third argument of B<connect>()  is in reality an I<int> (and this is "
1330 "what 4.x BSD and libc4 and libc5 have).  Some POSIX confusion resulted in "
1331 "the present I<socklen_t>, also used by glibc.  See also B<accept>(2)."
1332 msgstr ""
1333
1334 #. type: Plain text
1335 #: build/C/man2/connect.2:263
1336 msgid "An example of the use of B<connect>()  is shown in B<getaddrinfo>(3)."
1337 msgstr ""
1338
1339 #. type: Plain text
1340 #: build/C/man2/connect.2:270
1341 msgid ""
1342 "B<accept>(2), B<bind>(2), B<getsockname>(2), B<listen>(2), B<socket>(2), "
1343 "B<path_resolution>(7)"
1344 msgstr ""
1345
1346 #. type: TH
1347 #: build/C/man3/getifaddrs.3:36
1348 #, no-wrap
1349 msgid "GETIFADDRS"
1350 msgstr ""
1351
1352 #. type: TH
1353 #: build/C/man3/getifaddrs.3:36
1354 #, no-wrap
1355 msgid "2012-11-11"
1356 msgstr ""
1357
1358 #. type: TH
1359 #: build/C/man3/getifaddrs.3:36 build/C/man3/if_nameindex.3:26 build/C/man3/if_nametoindex.3:25
1360 #, no-wrap
1361 msgid "GNU"
1362 msgstr ""
1363
1364 #. type: Plain text
1365 #: build/C/man3/getifaddrs.3:39
1366 msgid "getifaddrs, freeifaddrs - get interface addresses"
1367 msgstr ""
1368
1369 #. type: Plain text
1370 #: build/C/man3/getifaddrs.3:43
1371 #, no-wrap
1372 msgid ""
1373 "B<#include E<lt>sys/types.hE<gt>>\n"
1374 "B<#include E<lt>ifaddrs.hE<gt>>\n"
1375 msgstr ""
1376
1377 #. type: Plain text
1378 #: build/C/man3/getifaddrs.3:45
1379 #, no-wrap
1380 msgid "B<int getifaddrs(struct ifaddrs **>I<ifap>B<);>\n"
1381 msgstr ""
1382
1383 #. type: Plain text
1384 #: build/C/man3/getifaddrs.3:47
1385 #, no-wrap
1386 msgid "B<void freeifaddrs(struct ifaddrs *>I<ifa>B<);>\n"
1387 msgstr ""
1388
1389 #. type: Plain text
1390 #: build/C/man3/getifaddrs.3:58
1391 msgid ""
1392 "The B<getifaddrs>()  function creates a linked list of structures describing "
1393 "the network interfaces of the local system, and stores the address of the "
1394 "first item of the list in I<*ifap>.  The list consists of I<ifaddrs> "
1395 "structures, defined as follows:"
1396 msgstr ""
1397
1398 #. type: Plain text
1399 #: build/C/man3/getifaddrs.3:77
1400 #, no-wrap
1401 msgid ""
1402 "struct ifaddrs {\n"
1403 "    struct ifaddrs  *ifa_next;    /* Next item in list */\n"
1404 "    char            *ifa_name;    /* Name of interface */\n"
1405 "    unsigned int     ifa_flags;   /* Flags from SIOCGIFFLAGS */\n"
1406 "    struct sockaddr *ifa_addr;    /* Address of interface */\n"
1407 "    struct sockaddr *ifa_netmask; /* Netmask of interface */\n"
1408 "    union {\n"
1409 "        struct sockaddr *ifu_broadaddr;\n"
1410 "                         /* Broadcast address of interface */\n"
1411 "        struct sockaddr *ifu_dstaddr;\n"
1412 "                         /* Point-to-point destination address */\n"
1413 "    } ifa_ifu;\n"
1414 "#define              ifa_broadaddr ifa_ifu.ifu_broadaddr\n"
1415 "#define              ifa_dstaddr   ifa_ifu.ifu_dstaddr\n"
1416 "    void            *ifa_data;    /* Address-specific data */\n"
1417 "};\n"
1418 msgstr ""
1419
1420 #. type: Plain text
1421 #: build/C/man3/getifaddrs.3:84
1422 msgid ""
1423 "The I<ifa_next> field contains a pointer to the next structure on the list, "
1424 "or NULL if this is the last item of the list."
1425 msgstr ""
1426
1427 #.  The constant
1428 #.  .B IF NAMESIZE
1429 #.  indicates the maximum length of this field.
1430 #. type: Plain text
1431 #: build/C/man3/getifaddrs.3:91
1432 msgid "The I<ifa_name> points to the null-terminated interface name."
1433 msgstr ""
1434
1435 #. type: Plain text
1436 #: build/C/man3/getifaddrs.3:100
1437 msgid ""
1438 "The I<ifa_flags> field contains the interface flags, as returned by the "
1439 "B<SIOCGIFFLAGS> B<ioctl>(2)  operation (see B<netdevice>(7)  for a list of "
1440 "these flags)."
1441 msgstr ""
1442
1443 #. type: Plain text
1444 #: build/C/man3/getifaddrs.3:109
1445 msgid ""
1446 "The I<ifa_addr> field points to a structure containing the interface "
1447 "address.  (The I<sa_family> subfield should be consulted to determine the "
1448 "format of the address structure.)  This field may contain a NULL pointer."
1449 msgstr ""
1450
1451 #. type: Plain text
1452 #: build/C/man3/getifaddrs.3:116
1453 msgid ""
1454 "The I<ifa_netmask> field points to a structure containing the netmask "
1455 "associated with I<ifa_addr>, if applicable for the address family.  This "
1456 "field may contain a NULL pointer."
1457 msgstr ""
1458
1459 #. type: Plain text
1460 #: build/C/man3/getifaddrs.3:131
1461 msgid ""
1462 "Depending on whether the bit B<IFF_BROADCAST> or B<IFF_POINTOPOINT> is set "
1463 "in I<ifa_flags> (only one can be set at a time), either I<ifa_broadaddr> "
1464 "will contain the broadcast address associated with I<ifa_addr> (if "
1465 "applicable for the address family) or I<ifa_dstaddr> will contain the "
1466 "destination address of the point-to-point interface."
1467 msgstr ""
1468
1469 #. type: Plain text
1470 #: build/C/man3/getifaddrs.3:136
1471 msgid ""
1472 "The I<ifa_data> field points to a buffer containing address-family-specific "
1473 "data; this field may be NULL if there is no such data for this interface."
1474 msgstr ""
1475
1476 #. type: Plain text
1477 #: build/C/man3/getifaddrs.3:142
1478 msgid ""
1479 "The data returned by B<getifaddrs>()  is dynamically allocated and should be "
1480 "freed using B<freeifaddrs>()  when no longer needed."
1481 msgstr ""
1482
1483 #. type: Plain text
1484 #: build/C/man3/getifaddrs.3:149
1485 msgid ""
1486 "On success, B<getifaddrs>()  returns zero; on error, -1 is returned, and "
1487 "I<errno> is set appropriately."
1488 msgstr ""
1489
1490 #. type: Plain text
1491 #: build/C/man3/getifaddrs.3:162
1492 msgid ""
1493 "B<getifaddrs>()  may fail and set I<errno> for any of the errors specified "
1494 "for B<socket>(2), B<bind>(2), B<getsockname>(2), B<recvmsg>(2), "
1495 "B<sendto>(2), B<malloc>(3), or B<realloc>(3)."
1496 msgstr ""
1497
1498 #. type: Plain text
1499 #: build/C/man3/getifaddrs.3:170
1500 msgid ""
1501 "The B<getifaddrs>()  function first appeared in glibc 2.3, but before glibc "
1502 "2.3.3, the implementation only supported IPv4 addresses; IPv6 support was "
1503 "added in glibc 2.3.3.  Support of address families other than IPv4 is only "
1504 "available on kernels that support netlink."
1505 msgstr ""
1506
1507 #.  , but the BSD-derived documentation generally
1508 #.  appears to be confused and obsolete on this point.
1509 #.  i.e., commonly it still says one of them will be NULL, even if
1510 #.  the ifa_ifu union is already present
1511 #. type: Plain text
1512 #: build/C/man3/getifaddrs.3:190
1513 msgid ""
1514 "Not in POSIX.1-2001.  This function first appeared in BSDi and is present on "
1515 "the BSD systems, but with slightly different semantics "
1516 "documented\\(emreturning one entry per interface, not per address.  This "
1517 "means I<ifa_addr> and other fields can actually be NULL if the interface has "
1518 "no address, and no link-level address is returned if the interface has an IP "
1519 "address assigned.  Also, the way of choosing either I<ifa_broadaddr> or "
1520 "I<ifa_dstaddr> differs on various systems."
1521 msgstr ""
1522
1523 #. type: Plain text
1524 #: build/C/man3/getifaddrs.3:207
1525 msgid ""
1526 "The addresses returned on Linux will usually be the IPv4 and IPv6 addresses "
1527 "assigned to the interface, but also one B<AF_PACKET> address per interface "
1528 "containing lower-level details about the interface and its physical layer.  "
1529 "In this case, the I<ifa_data> field may contain a pointer to a I<struct "
1530 "rtnl_link_stats>, defined in I<E<lt>linux/if_link.hE<gt>> (in Linux 2.4 and "
1531 "earlier, I<struct net_device_stats>, defined in "
1532 "I<E<lt>linux/netdevice.hE<gt>>), which contains various interface attributes "
1533 "and statistics."
1534 msgstr ""
1535
1536 #. type: Plain text
1537 #: build/C/man3/getifaddrs.3:214
1538 msgid ""
1539 "The program below demonstrates the use of B<getifaddrs>(), B<freeifaddrs>(), "
1540 "and B<getnameinfo>(3).  Here is what we see when running this program on one "
1541 "system:"
1542 msgstr ""
1543
1544 #. type: Plain text
1545 #: build/C/man3/getifaddrs.3:228
1546 #, no-wrap
1547 msgid ""
1548 "$ B<./a.out>\n"
1549 "lo      address family: 17 (AF_PACKET)\n"
1550 "eth0    address family: 17 (AF_PACKET)\n"
1551 "lo      address family: 2 (AF_INET)\n"
1552 "        address: E<lt>127.0.0.1E<gt>\n"
1553 "eth0    address family: 2 (AF_INET)\n"
1554 "        address: E<lt>10.1.1.4E<gt>\n"
1555 "lo      address family: 10 (AF_INET6)\n"
1556 "        address: E<lt>::1E<gt>\n"
1557 "eth0    address family: 10 (AF_INET6)\n"
1558 "        address: E<lt>fe80::2d0:59ff:feda:eb51%eth0E<gt>\n"
1559 msgstr ""
1560
1561 #. type: SS
1562 #: build/C/man3/getifaddrs.3:230 build/C/man3/if_nameindex.3:120 build/C/man2/recvmmsg.2:206
1563 #, no-wrap
1564 msgid "Program source"
1565 msgstr ""
1566
1567 #. type: Plain text
1568 #: build/C/man3/getifaddrs.3:240
1569 #, no-wrap
1570 msgid ""
1571 "#include E<lt>arpa/inet.hE<gt>\n"
1572 "#include E<lt>sys/socket.hE<gt>\n"
1573 "#include E<lt>netdb.hE<gt>\n"
1574 "#include E<lt>ifaddrs.hE<gt>\n"
1575 "#include E<lt>stdio.hE<gt>\n"
1576 "#include E<lt>stdlib.hE<gt>\n"
1577 "#include E<lt>unistd.hE<gt>\n"
1578 msgstr ""
1579
1580 #. type: Plain text
1581 #: build/C/man3/getifaddrs.3:247
1582 #, no-wrap
1583 msgid ""
1584 "int\n"
1585 "main(int argc, char *argv[])\n"
1586 "{\n"
1587 "    struct ifaddrs *ifaddr, *ifa;\n"
1588 "    int family, s;\n"
1589 "    char host[NI_MAXHOST];\n"
1590 msgstr ""
1591
1592 #. type: Plain text
1593 #: build/C/man3/getifaddrs.3:252
1594 #, no-wrap
1595 msgid ""
1596 "    if (getifaddrs(&ifaddr) == -1) {\n"
1597 "        perror(\"getifaddrs\");\n"
1598 "        exit(EXIT_FAILURE);\n"
1599 "    }\n"
1600 msgstr ""
1601
1602 #. type: Plain text
1603 #: build/C/man3/getifaddrs.3:255
1604 #, no-wrap
1605 msgid ""
1606 "    /* Walk through linked list, maintaining head pointer so we\n"
1607 "       can free list later */\n"
1608 msgstr ""
1609
1610 #. type: Plain text
1611 #: build/C/man3/getifaddrs.3:259
1612 #, no-wrap
1613 msgid ""
1614 "    for (ifa = ifaddr; ifa != NULL; ifa = ifa-E<gt>ifa_next) {\n"
1615 "        if (ifa-E<gt>ifa_addr == NULL)\n"
1616 "            continue;\n"
1617 msgstr ""
1618
1619 #. type: Plain text
1620 #: build/C/man3/getifaddrs.3:261
1621 #, no-wrap
1622 msgid "        family = ifa-E<gt>ifa_addr-E<gt>sa_family;\n"
1623 msgstr ""
1624
1625 #. type: Plain text
1626 #: build/C/man3/getifaddrs.3:264
1627 #, no-wrap
1628 msgid ""
1629 "        /* Display interface name and family (including symbolic\n"
1630 "           form of the latter for the common families) */\n"
1631 msgstr ""
1632
1633 #. type: Plain text
1634 #: build/C/man3/getifaddrs.3:270
1635 #, no-wrap
1636 msgid ""
1637 "        printf(\"%s\\t  address family: %d%s\\en\",\n"
1638 "                ifa-E<gt>ifa_name, family,\n"
1639 "                (family == AF_PACKET) ? \" (AF_PACKET)\" :\n"
1640 "                (family == AF_INET) ?   \" (AF_INET)\" :\n"
1641 "                (family == AF_INET6) ?  \" (AF_INET6)\" : \"\");\n"
1642 msgstr ""
1643
1644 #. type: Plain text
1645 #: build/C/man3/getifaddrs.3:272
1646 #, no-wrap
1647 msgid "        /* For an AF_INET* interface address, display the address */\n"
1648 msgstr ""
1649
1650 #. type: Plain text
1651 #: build/C/man3/getifaddrs.3:285
1652 #, no-wrap
1653 msgid ""
1654 "        if (family == AF_INET || family == AF_INET6) {\n"
1655 "            s = getnameinfo(ifa-E<gt>ifa_addr,\n"
1656 "                    (family == AF_INET) ? sizeof(struct sockaddr_in) :\n"
1657 "                                          sizeof(struct sockaddr_in6),\n"
1658 "                    host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);\n"
1659 "            if (s != 0) {\n"
1660 "                printf(\"getnameinfo() failed: %s\\en\", gai_strerror(s));\n"
1661 "                exit(EXIT_FAILURE);\n"
1662 "            }\n"
1663 "            printf(\"\\etaddress: E<lt>%sE<gt>\\en\", host);\n"
1664 "        }\n"
1665 "    }\n"
1666 msgstr ""
1667
1668 #. type: Plain text
1669 #: build/C/man3/getifaddrs.3:289
1670 #, no-wrap
1671 msgid ""
1672 "    freeifaddrs(ifaddr);\n"
1673 "    exit(EXIT_SUCCESS);\n"
1674 "}\n"
1675 msgstr ""
1676
1677 #. type: Plain text
1678 #: build/C/man3/getifaddrs.3:296
1679 msgid "B<bind>(2), B<getsockname>(2), B<socket>(2), B<packet>(7), B<ifconfig>(8)"
1680 msgstr ""
1681
1682 #. type: TH
1683 #: build/C/man2/getsockname.2:40
1684 #, no-wrap
1685 msgid "GETSOCKNAME"
1686 msgstr ""
1687
1688 #. type: Plain text
1689 #: build/C/man2/getsockname.2:43
1690 msgid "getsockname - get socket name"
1691 msgstr ""
1692
1693 #. type: Plain text
1694 #: build/C/man2/getsockname.2:49
1695 #, no-wrap
1696 msgid ""
1697 "B<int getsockname(int >I<sockfd>B<, struct sockaddr *>I<addr>B<, socklen_t "
1698 "*>I<addrlen>B<);>\n"
1699 msgstr ""
1700
1701 #. type: Plain text
1702 #: build/C/man2/getsockname.2:62
1703 msgid ""
1704 "B<getsockname>()  returns the current address to which the socket I<sockfd> "
1705 "is bound, in the buffer pointed to by I<addr>.  The I<addrlen> argument "
1706 "should be initialized to indicate the amount of space (in bytes) pointed to "
1707 "by I<addr>.  On return it contains the actual size of the socket address."
1708 msgstr ""
1709
1710 #. type: Plain text
1711 #: build/C/man2/getsockname.2:78 build/C/man2/getsockopt.2:142 build/C/man2/listen.2:96
1712 msgid "The argument I<sockfd> is not a valid descriptor."
1713 msgstr ""
1714
1715 #. type: Plain text
1716 #: build/C/man2/getsockname.2:84
1717 msgid ""
1718 "The I<addr> argument points to memory not in a valid part of the process "
1719 "address space."
1720 msgstr ""
1721
1722 #. type: Plain text
1723 #: build/C/man2/getsockname.2:88
1724 msgid "I<addrlen> is invalid (e.g., is negative)."
1725 msgstr ""
1726
1727 #. type: TP
1728 #: build/C/man2/getsockname.2:88 build/C/man3/if_nameindex.3:83 build/C/man2/send.2:335
1729 #, no-wrap
1730 msgid "B<ENOBUFS>"
1731 msgstr ""
1732
1733 #. type: Plain text
1734 #: build/C/man2/getsockname.2:92
1735 msgid ""
1736 "Insufficient resources were available in the system to perform the "
1737 "operation."
1738 msgstr ""
1739
1740 #. type: Plain text
1741 #: build/C/man2/getsockname.2:97 build/C/man2/getsockopt.2:171
1742 msgid "The argument I<sockfd> is a file, not a socket."
1743 msgstr ""
1744
1745 #.  SVr4 documents additional ENOMEM
1746 #.  and ENOSR error codes.
1747 #. type: Plain text
1748 #: build/C/man2/getsockname.2:103
1749 msgid ""
1750 "SVr4, 4.4BSD (the B<getsockname>()  function call appeared in 4.2BSD), "
1751 "POSIX.1-2001."
1752 msgstr ""
1753
1754 #. type: Plain text
1755 #: build/C/man2/getsockname.2:112
1756 msgid ""
1757 "The third argument of B<getsockname>()  is in reality an I<int *> (and this "
1758 "is what 4.x BSD and libc4 and libc5 have).  Some POSIX confusion resulted in "
1759 "the present I<socklen_t>, also used by glibc.  See also B<accept>(2)."
1760 msgstr ""
1761
1762 #. type: Plain text
1763 #: build/C/man2/getsockname.2:119
1764 msgid ""
1765 "B<bind>(2), B<socket>(2), B<getifaddrs>(3), B<ip>(7), B<socket>(7), "
1766 "B<unix>(7)"
1767 msgstr ""
1768
1769 #. type: TH
1770 #: build/C/man2/getsockopt.2:44
1771 #, no-wrap
1772 msgid "GETSOCKOPT"
1773 msgstr ""
1774
1775 #. type: Plain text
1776 #: build/C/man2/getsockopt.2:47
1777 msgid "getsockopt, setsockopt - get and set options on sockets"
1778 msgstr ""
1779
1780 #. type: Plain text
1781 #: build/C/man2/getsockopt.2:57
1782 #, no-wrap
1783 msgid ""
1784 "B<int getsockopt(int >I<sockfd>B<, int >I<level>B<, int >I<optname>B<,>\n"
1785 "B<               void *>I<optval>B<, socklen_t *>I<optlen>B<);>\n"
1786 "B<int setsockopt(int >I<sockfd>B<, int >I<level>B<, int >I<optname>B<,>\n"
1787 "B<               const void *>I<optval>B<, socklen_t >I<optlen>B<);>\n"
1788 msgstr ""
1789
1790 #. type: Plain text
1791 #: build/C/man2/getsockopt.2:67
1792 msgid ""
1793 "B<getsockopt>()  and B<setsockopt>()  manipulate options for the socket "
1794 "referred to by the file descriptor I<sockfd>.  Options may exist at multiple "
1795 "protocol levels; they are always present at the uppermost socket level."
1796 msgstr ""
1797
1798 #. type: Plain text
1799 #: build/C/man2/getsockopt.2:86
1800 msgid ""
1801 "When manipulating socket options, the level at which the option resides and "
1802 "the name of the option must be specified.  To manipulate options at the "
1803 "sockets API level, I<level> is specified as B<SOL_SOCKET>.  To manipulate "
1804 "options at any other level the protocol number of the appropriate protocol "
1805 "controlling the option is supplied.  For example, to indicate that an option "
1806 "is to be interpreted by the B<TCP> protocol, I<level> should be set to the "
1807 "protocol number of B<TCP>; see B<getprotoent>(3)."
1808 msgstr ""
1809
1810 #. type: Plain text
1811 #: build/C/man2/getsockopt.2:108
1812 msgid ""
1813 "The arguments I<optval> and I<optlen> are used to access option values for "
1814 "B<setsockopt>().  For B<getsockopt>()  they identify a buffer in which the "
1815 "value for the requested option(s) are to be returned.  For B<getsockopt>(), "
1816 "I<optlen> is a value-result argument, initially containing the size of the "
1817 "buffer pointed to by I<optval>, and modified on return to indicate the "
1818 "actual size of the value returned.  If no option value is to be supplied or "
1819 "returned, I<optval> may be NULL."
1820 msgstr ""
1821
1822 #. type: Plain text
1823 #: build/C/man2/getsockopt.2:118
1824 msgid ""
1825 "I<Optname> and any specified options are passed uninterpreted to the "
1826 "appropriate protocol module for interpretation.  The include file "
1827 "I<E<lt>sys/socket.hE<gt>> contains definitions for socket level options, "
1828 "described below.  Options at other protocol levels vary in format and name; "
1829 "consult the appropriate entries in section 4 of the manual."
1830 msgstr ""
1831
1832 #. type: Plain text
1833 #: build/C/man2/getsockopt.2:127
1834 msgid ""
1835 "Most socket-level options utilize an I<int> argument for I<optval>.  For "
1836 "B<setsockopt>(), the argument should be nonzero to enable a boolean option, "
1837 "or zero if the option is to be disabled."
1838 msgstr ""
1839
1840 #. type: Plain text
1841 #: build/C/man2/getsockopt.2:131
1842 msgid ""
1843 "For a description of the available socket options see B<socket>(7)  and the "
1844 "appropriate protocol man pages."
1845 msgstr ""
1846
1847 #. type: Plain text
1848 #: build/C/man2/getsockopt.2:152
1849 msgid ""
1850 "The address pointed to by I<optval> is not in a valid part of the process "
1851 "address space.  For B<getsockopt>(), this error may also be returned if "
1852 "I<optlen> is not in a valid part of the process address space."
1853 msgstr ""
1854
1855 #. type: Plain text
1856 #: build/C/man2/getsockopt.2:163
1857 msgid ""
1858 "I<optlen> invalid in B<setsockopt>().  In some cases this error can also "
1859 "occur for an invalid value in I<optval> (e.g., for the B<IP_ADD_MEMBERSHIP> "
1860 "option described in B<ip>(7))."
1861 msgstr ""
1862
1863 #. type: TP
1864 #: build/C/man2/getsockopt.2:163
1865 #, no-wrap
1866 msgid "B<ENOPROTOOPT>"
1867 msgstr ""
1868
1869 #. type: Plain text
1870 #: build/C/man2/getsockopt.2:166
1871 msgid "The option is unknown at the level indicated."
1872 msgstr ""
1873
1874 #.  SVr4 documents additional ENOMEM and ENOSR error codes, but does
1875 #.  not document the
1876 #.  .BR SO_SNDLOWAT ", " SO_RCVLOWAT ", " SO_SNDTIMEO ", " SO_RCVTIMEO
1877 #.  options
1878 #. type: Plain text
1879 #: build/C/man2/getsockopt.2:178
1880 msgid "SVr4, 4.4BSD (these system calls first appeared in 4.2BSD), POSIX.1-2001."
1881 msgstr ""
1882
1883 #. type: Plain text
1884 #: build/C/man2/getsockopt.2:199
1885 msgid ""
1886 "The I<optlen> argument of B<getsockopt>()  and B<setsockopt>()  is in "
1887 "reality an I<int [*]> (and this is what 4.x BSD and libc4 and libc5 have).  "
1888 "Some POSIX confusion resulted in the present I<socklen_t>, also used by "
1889 "glibc.  See also B<accept>(2)."
1890 msgstr ""
1891
1892 #. type: Plain text
1893 #: build/C/man2/getsockopt.2:202
1894 msgid ""
1895 "Several of the socket options should be handled at lower levels of the "
1896 "system."
1897 msgstr ""
1898
1899 #. type: Plain text
1900 #: build/C/man2/getsockopt.2:210
1901 msgid ""
1902 "B<ioctl>(2), B<socket>(2), B<getprotoent>(3), B<protocols>(5), B<socket>(7), "
1903 "B<tcp>(7), B<unix>(7)"
1904 msgstr ""
1905
1906 #. type: TH
1907 #: build/C/man3/if_nameindex.3:26
1908 #, no-wrap
1909 msgid "IF_NAMEINDEX"
1910 msgstr ""
1911
1912 #. type: TH
1913 #: build/C/man3/if_nameindex.3:26
1914 #, no-wrap
1915 msgid "2012-11-21"
1916 msgstr ""
1917
1918 #. type: Plain text
1919 #: build/C/man3/if_nameindex.3:29
1920 msgid "if_nameindex, if_freenameindex - get network interface names and indexes"
1921 msgstr ""
1922
1923 #. type: Plain text
1924 #: build/C/man3/if_nameindex.3:32 build/C/man3/if_nametoindex.3:32
1925 #, no-wrap
1926 msgid "B<#include E<lt>net/if.hE<gt>>\n"
1927 msgstr ""
1928
1929 #. type: Plain text
1930 #: build/C/man3/if_nameindex.3:35
1931 #, no-wrap
1932 msgid ""
1933 "B<struct if_nameindex *if_nameindex(void);>\n"
1934 "B<void if_freenameindex(struct if_nameindex *>I<ptr>B<);>\n"
1935 msgstr ""
1936
1937 #. type: Plain text
1938 #: build/C/man3/if_nameindex.3:46
1939 msgid ""
1940 "The B<if_nameindex>()  function returns an array of I<if_nameindex> "
1941 "structures, each containing information about one of the network interfaces "
1942 "on the local system.  The I<if_nameindex> structure contains at least the "
1943 "following entries:"
1944 msgstr ""
1945
1946 #. type: Plain text
1947 #: build/C/man3/if_nameindex.3:51
1948 #, no-wrap
1949 msgid ""
1950 "    unsigned int if_index; /* Index of interface (1, 2, ...) */\n"
1951 "    char        *if_name;  /* Null-terminated name (\"eth0\", etc.) */\n"
1952 msgstr ""
1953
1954 #. type: Plain text
1955 #: build/C/man3/if_nameindex.3:65
1956 msgid ""
1957 "The I<if_index> field contains the interface index.  The I<ifa_name> field "
1958 "points to the null-terminated interface name.  The end of the array is "
1959 "indicated by entry with I<if_index> set to zero and I<ifa_name> set to NULL."
1960 msgstr ""
1961
1962 #. type: Plain text
1963 #: build/C/man3/if_nameindex.3:71
1964 msgid ""
1965 "The data structure returned by B<if_nameindex>()  is dynamically allocated "
1966 "and should be freed using B<if_freenameindex>()  when no longer needed."
1967 msgstr ""
1968
1969 #. type: Plain text
1970 #: build/C/man3/if_nameindex.3:78
1971 msgid ""
1972 "On success, B<if_nameindex>()  returns pointer to the array; on error, a "
1973 "NULL pointer is returned, and I<errno> is set appropriately."
1974 msgstr ""
1975
1976 #. type: Plain text
1977 #: build/C/man3/if_nameindex.3:83
1978 msgid "B<if_nameindex>()  may fail and set I<errno> if:"
1979 msgstr ""
1980
1981 #. type: Plain text
1982 #: build/C/man3/if_nameindex.3:86
1983 msgid "Insufficient resources available."
1984 msgstr ""
1985
1986 #. type: Plain text
1987 #: build/C/man3/if_nameindex.3:97
1988 msgid ""
1989 "B<if_nameindex>()  may also fail for any of the errors specified for "
1990 "B<socket>(2), B<bind>(2), B<ioctl>(2), B<getsockname>(2), B<recvmsg>(2), "
1991 "B<sendto>(2), or B<malloc>(3)."
1992 msgstr ""
1993
1994 #. type: Plain text
1995 #: build/C/man3/if_nameindex.3:104
1996 msgid ""
1997 "The B<if_nameindex>()  function first appeared in glibc 2.1, but before "
1998 "glibc 2.3.4, the implementation only supported interfaces with IPv4 "
1999 "addresses.  Support of interfaces that don't have IPv4 addresses is only "
2000 "available on kernels that support netlink."
2001 msgstr ""
2002
2003 #. type: Plain text
2004 #: build/C/man3/if_nameindex.3:106 build/C/man3/if_nametoindex.3:87
2005 msgid "RFC\\ 3493, POSIX.1-2001."
2006 msgstr ""
2007
2008 #. type: Plain text
2009 #: build/C/man3/if_nameindex.3:108 build/C/man3/if_nametoindex.3:89
2010 msgid "This function first appeared in BSDi."
2011 msgstr ""
2012
2013 #. type: Plain text
2014 #: build/C/man3/if_nameindex.3:112
2015 msgid ""
2016 "The program below demonstrates the use of the functions described on this "
2017 "page.  An example of the output this program might produce is the following:"
2018 msgstr ""
2019
2020 #. type: Plain text
2021 #: build/C/man3/if_nameindex.3:118
2022 #, no-wrap
2023 msgid ""
2024 "$ B<./a.out>I<\n"
2025 "1: lo\n"
2026 "2: wlan0\n"
2027 "3: em1>\n"
2028 msgstr ""
2029
2030 #. type: Plain text
2031 #: build/C/man3/if_nameindex.3:126
2032 #, no-wrap
2033 msgid ""
2034 "#include E<lt>net/if.hE<gt>\n"
2035 "#include E<lt>stdio.hE<gt>\n"
2036 "#include E<lt>stdlib.hE<gt>\n"
2037 "#include E<lt>unistd.hE<gt>\n"
2038 msgstr ""
2039
2040 #. type: Plain text
2041 #: build/C/man3/if_nameindex.3:131
2042 #, no-wrap
2043 msgid ""
2044 "int\n"
2045 "main(int argc, char *argv[])\n"
2046 "{\n"
2047 "    struct if_nameindex *if_ni, *i;\n"
2048 msgstr ""
2049
2050 #. type: Plain text
2051 #: build/C/man3/if_nameindex.3:137
2052 #, no-wrap
2053 msgid ""
2054 "    if_ni = if_nameindex();\n"
2055 "    if (if_ni == NULL) {\n"
2056 "        perror(\"if_nameindex\");\n"
2057 "        exit(EXIT_FAILURE);\n"
2058 "    }\n"
2059 msgstr ""
2060
2061 #. type: Plain text
2062 #: build/C/man3/if_nameindex.3:140
2063 #, no-wrap
2064 msgid ""
2065 "    for (i = if_ni; ! (i-E<gt>if_index == 0 && i-E<gt>if_name == NULL); "
2066 "i++)\n"
2067 "        printf(\"%u: %s\\en\", i-E<gt>if_index, i-E<gt>if_name);\n"
2068 msgstr ""
2069
2070 #. type: Plain text
2071 #: build/C/man3/if_nameindex.3:142
2072 #, no-wrap
2073 msgid "    if_freenameindex(if_ni);\n"
2074 msgstr ""
2075
2076 #. type: Plain text
2077 #: build/C/man3/if_nameindex.3:145 build/C/man2/select.2:573
2078 #, no-wrap
2079 msgid ""
2080 "    exit(EXIT_SUCCESS);\n"
2081 "}\n"
2082 msgstr ""
2083
2084 #. type: Plain text
2085 #: build/C/man3/if_nameindex.3:153
2086 msgid ""
2087 "B<getsockopt>(2), B<setsockopt>(2), B<getifaddrs>(3), B<if_indextoname>(3), "
2088 "B<if_nametoindex>(3), B<ifconfig>(8)"
2089 msgstr ""
2090
2091 #. type: TH
2092 #: build/C/man3/if_nametoindex.3:25
2093 #, no-wrap
2094 msgid "IF_NAMETOINDEX"
2095 msgstr ""
2096
2097 #. type: TH
2098 #: build/C/man3/if_nametoindex.3:25
2099 #, no-wrap
2100 msgid "2012-12-14"
2101 msgstr ""
2102
2103 #. type: Plain text
2104 #: build/C/man3/if_nametoindex.3:29
2105 msgid ""
2106 "if_nametoindex, if_indextoname - mappings between network interface names "
2107 "and indexes"
2108 msgstr ""
2109
2110 #. type: Plain text
2111 #: build/C/man3/if_nametoindex.3:34
2112 #, no-wrap
2113 msgid "B<unsigned int if_nametoindex(const char *>I<ifname>B<);>\n"
2114 msgstr ""
2115
2116 #. type: Plain text
2117 #: build/C/man3/if_nametoindex.3:36
2118 #, no-wrap
2119 msgid "B<char *if_indextoname(unsigned int ifindex, char *>I<ifname>B<);>\n"
2120 msgstr ""
2121
2122 #. type: Plain text
2123 #: build/C/man3/if_nametoindex.3:43
2124 msgid ""
2125 "The B<if_nametoindex>()  function returns the index of the network interface "
2126 "corresponding to the name I<ifname>."
2127 msgstr ""
2128
2129 #. type: Plain text
2130 #: build/C/man3/if_nametoindex.3:54
2131 msgid ""
2132 "The B<if_indextoname>()  function returns the name of the network interface "
2133 "corresponding to the interface index I<ifindex>.  The name is placed in the "
2134 "buffer pointed to by I<ifname>.  The buffer must allow for the storage of at "
2135 "least B<IF_NAMESIZE> bytes."
2136 msgstr ""
2137
2138 #. type: Plain text
2139 #: build/C/man3/if_nametoindex.3:61
2140 msgid ""
2141 "On success, B<if_nametoindex>()  returns the index number of the network "
2142 "interface; on error, 0 is returned and I<errno> is set appropriately."
2143 msgstr ""
2144
2145 #. type: Plain text
2146 #: build/C/man3/if_nametoindex.3:69
2147 msgid ""
2148 "On success, B<if_indextoname>()  returns I<ifname>; on error, NULL is "
2149 "returned and I<errno> is set appropriately."
2150 msgstr ""
2151
2152 #. type: Plain text
2153 #: build/C/man3/if_nametoindex.3:74
2154 msgid "B<if_indextoname>()  may fail and set I<errno> if:"
2155 msgstr ""
2156
2157 #. type: TP
2158 #: build/C/man3/if_nametoindex.3:74
2159 #, no-wrap
2160 msgid "B<ENXIO>"
2161 msgstr ""
2162
2163 #. type: Plain text
2164 #: build/C/man3/if_nametoindex.3:77
2165 msgid "No interface found for the index."
2166 msgstr ""
2167
2168 #. type: Plain text
2169 #: build/C/man3/if_nametoindex.3:85
2170 msgid ""
2171 "B<if_nametoindex>()  and B<if_indextoname>()  may also fail for any of the "
2172 "errors specified for B<socket>(2)  or B<ioctl>(2)."
2173 msgstr ""
2174
2175 #. type: Plain text
2176 #: build/C/man3/if_nametoindex.3:93
2177 msgid "B<getifaddrs>(3), B<if_nameindex>(3), B<ifconfig>(8)"
2178 msgstr ""
2179
2180 #. type: TH
2181 #: build/C/man2/listen.2:45
2182 #, no-wrap
2183 msgid "LISTEN"
2184 msgstr ""
2185
2186 #. type: TH
2187 #: build/C/man2/listen.2:45
2188 #, no-wrap
2189 msgid "2008-11-20"
2190 msgstr ""
2191
2192 #. type: Plain text
2193 #: build/C/man2/listen.2:48
2194 msgid "listen - listen for connections on a socket"
2195 msgstr ""
2196
2197 #. type: Plain text
2198 #: build/C/man2/listen.2:55
2199 #, no-wrap
2200 msgid "B<int listen(int >I<sockfd>B<, int >I<backlog>B<);>\n"
2201 msgstr ""
2202
2203 #. type: Plain text
2204 #: build/C/man2/listen.2:63
2205 msgid ""
2206 "B<listen>()  marks the socket referred to by I<sockfd> as a passive socket, "
2207 "that is, as a socket that will be used to accept incoming connection "
2208 "requests using B<accept>(2)."
2209 msgstr ""
2210
2211 #. type: Plain text
2212 #: build/C/man2/listen.2:70
2213 msgid ""
2214 "The I<sockfd> argument is a file descriptor that refers to a socket of type "
2215 "B<SOCK_STREAM> or B<SOCK_SEQPACKET>."
2216 msgstr ""
2217
2218 #. type: Plain text
2219 #: build/C/man2/listen.2:82
2220 msgid ""
2221 "The I<backlog> argument defines the maximum length to which the queue of "
2222 "pending connections for I<sockfd> may grow.  If a connection request arrives "
2223 "when the queue is full, the client may receive an error with an indication "
2224 "of B<ECONNREFUSED> or, if the underlying protocol supports retransmission, "
2225 "the request may be ignored so that a later reattempt at connection succeeds."
2226 msgstr ""
2227
2228 #. type: Plain text
2229 #: build/C/man2/listen.2:91
2230 msgid "Another socket is already listening on the same port."
2231 msgstr ""
2232
2233 #. type: Plain text
2234 #: build/C/man2/listen.2:101 build/C/man2/send.2:354
2235 msgid "The argument I<sockfd> is not a socket."
2236 msgstr ""
2237
2238 #. type: Plain text
2239 #: build/C/man2/listen.2:106
2240 msgid "The socket is not of a type that supports the B<listen>()  operation."
2241 msgstr ""
2242
2243 #. type: Plain text
2244 #: build/C/man2/listen.2:111
2245 msgid ""
2246 "4.4BSD, POSIX.1-2001.  The B<listen>()  function call first appeared in "
2247 "4.2BSD."
2248 msgstr ""
2249
2250 #. type: Plain text
2251 #: build/C/man2/listen.2:113
2252 msgid "To accept connections, the following steps are performed:"
2253 msgstr ""
2254
2255 #. type: TP
2256 #: build/C/man2/listen.2:114 build/C/man2/select_tut.2:347
2257 #, no-wrap
2258 msgid "1."
2259 msgstr ""
2260
2261 #. type: Plain text
2262 #: build/C/man2/listen.2:117
2263 msgid "A socket is created with B<socket>(2)."
2264 msgstr ""
2265
2266 #. type: TP
2267 #: build/C/man2/listen.2:117 build/C/man2/select_tut.2:356
2268 #, no-wrap
2269 msgid "2."
2270 msgstr ""
2271
2272 #. type: Plain text
2273 #: build/C/man2/listen.2:123
2274 msgid ""
2275 "The socket is bound to a local address using B<bind>(2), so that other "
2276 "sockets may be B<connect>(2)ed to it."
2277 msgstr ""
2278
2279 #. type: TP
2280 #: build/C/man2/listen.2:123 build/C/man2/select_tut.2:360
2281 #, no-wrap
2282 msgid "3."
2283 msgstr ""
2284
2285 #. type: Plain text
2286 #: build/C/man2/listen.2:127
2287 msgid ""
2288 "A willingness to accept incoming connections and a queue limit for incoming "
2289 "connections are specified with B<listen>()."
2290 msgstr ""
2291
2292 #. type: TP
2293 #: build/C/man2/listen.2:127 build/C/man2/select_tut.2:367
2294 #, no-wrap
2295 msgid "4."
2296 msgstr ""
2297
2298 #. type: Plain text
2299 #: build/C/man2/listen.2:130
2300 msgid "Connections are accepted with B<accept>(2)."
2301 msgstr ""
2302
2303 #. type: Plain text
2304 #: build/C/man2/listen.2:153
2305 msgid ""
2306 "The behavior of the I<backlog> argument on TCP sockets changed with Linux "
2307 "2.2.  Now it specifies the queue length for I<completely> established "
2308 "sockets waiting to be accepted, instead of the number of incomplete "
2309 "connection requests.  The maximum length of the queue for incomplete sockets "
2310 "can be set using I</proc/sys/net/ipv4/tcp_max_syn_backlog>.  When syncookies "
2311 "are enabled there is no logical maximum length and this setting is ignored.  "
2312 "See B<tcp>(7)  for more information."
2313 msgstr ""
2314
2315 #.  The following is now rather historic information (MTK, Jun 05)
2316 #.  Don't rely on this value in portable applications since BSD
2317 #.  (and some BSD-derived systems) limit the backlog to 5.
2318 #. type: Plain text
2319 #: build/C/man2/listen.2:166
2320 msgid ""
2321 "If the I<backlog> argument is greater than the value in "
2322 "I</proc/sys/net/core/somaxconn>, then it is silently truncated to that "
2323 "value; the default value in this file is 128.  In kernels before 2.4.25, "
2324 "this limit was a hard coded value, B<SOMAXCONN>, with the value 128."
2325 msgstr ""
2326
2327 #. type: Plain text
2328 #: build/C/man2/listen.2:175
2329 msgid "B<accept>(2), B<bind>(2), B<connect>(2), B<socket>(2), B<socket>(7)"
2330 msgstr ""
2331
2332 #. type: TH
2333 #: build/C/man2/recv.2:41
2334 #, no-wrap
2335 msgid "RECV"
2336 msgstr ""
2337
2338 #. type: TH
2339 #: build/C/man2/recv.2:41
2340 #, no-wrap
2341 msgid "2012-12-21"
2342 msgstr ""
2343
2344 #. type: Plain text
2345 #: build/C/man2/recv.2:44
2346 msgid "recv, recvfrom, recvmsg - receive a message from a socket"
2347 msgstr ""
2348
2349 #. type: Plain text
2350 #: build/C/man2/recv.2:49 build/C/man2/select.2:53 build/C/man2/select_tut.2:47
2351 #, no-wrap
2352 msgid "B<#include E<lt>sys/types.hE<gt>>\n"
2353 msgstr ""
2354
2355 #. type: Plain text
2356 #: build/C/man2/recv.2:53
2357 #, no-wrap
2358 msgid ""
2359 "B<ssize_t recv(int >I<sockfd>B<, void *>I<buf>B<, size_t >I<len>B<, int "
2360 ">I<flags>B<);>\n"
2361 msgstr ""
2362
2363 #. type: Plain text
2364 #: build/C/man2/recv.2:56
2365 #, no-wrap
2366 msgid ""
2367 "B<ssize_t recvfrom(int >I<sockfd>B<, void *>I<buf>B<, size_t >I<len>B<, int "
2368 ">I<flags>B<,>\n"
2369 "B<                 struct sockaddr *>I<src_addr>B<, socklen_t "
2370 "*>I<addrlen>B<);>\n"
2371 msgstr ""
2372
2373 #. type: Plain text
2374 #: build/C/man2/recv.2:58
2375 #, no-wrap
2376 msgid ""
2377 "B<ssize_t recvmsg(int >I<sockfd>B<, struct msghdr *>I<msg>B<, int "
2378 ">I<flags>B<);>\n"
2379 msgstr ""
2380
2381 #. type: Plain text
2382 #: build/C/man2/recv.2:66
2383 msgid ""
2384 "The B<recvfrom>()  and B<recvmsg>()  calls are used to receive messages from "
2385 "a socket, and may be used to receive data on a socket whether or not it is "
2386 "connection-oriented."
2387 msgstr ""
2388
2389 #.  (Note: for datagram sockets in both the UNIX and Internet domains,
2390 #.  .I src_addr
2391 #.  is filled in.
2392 #.  .I src_addr
2393 #.  is also filled in for stream sockets in the UNIX domain, but is not
2394 #.  filled in for stream sockets in the Internet domain.)
2395 #.  [The above notes on AF_UNIX and AF_INET sockets apply as at
2396 #.  Kernel 2.4.18. (MTK, 22 Jul 02)]
2397 #. type: Plain text
2398 #: build/C/man2/recv.2:95
2399 msgid ""
2400 "If I<src_addr> is not NULL, and the underlying protocol provides the source "
2401 "address, this source address is filled in.  When I<src_addr> is NULL, "
2402 "nothing is filled in; in this case, I<addrlen> is not used, and should also "
2403 "be NULL.  The argument I<addrlen> is a value-result argument, which the "
2404 "caller should initialize before the call to the size of the buffer "
2405 "associated with I<src_addr>, and modified on return to indicate the actual "
2406 "size of the source address.  The returned address is truncated if the buffer "
2407 "provided is too small; in this case, I<addrlen> will return a value greater "
2408 "than was supplied to the call."
2409 msgstr ""
2410
2411 #. type: Plain text
2412 #: build/C/man2/recv.2:107
2413 msgid ""
2414 "The B<recv>()  call is normally used only on a I<connected> socket (see "
2415 "B<connect>(2))  and is identical to B<recvfrom>()  with a NULL I<src_addr> "
2416 "argument."
2417 msgstr ""
2418
2419 #. type: Plain text
2420 #: build/C/man2/recv.2:113
2421 msgid ""
2422 "All three routines return the length of the message on successful "
2423 "completion.  If a message is too long to fit in the supplied buffer, excess "
2424 "bytes may be discarded depending on the type of socket the message is "
2425 "received from."
2426 msgstr ""
2427
2428 #. type: Plain text
2429 #: build/C/man2/recv.2:123
2430 msgid ""
2431 "If no messages are available at the socket, the receive calls wait for a "
2432 "message to arrive, unless the socket is nonblocking (see B<fcntl>(2)), in "
2433 "which case the value -1 is returned and the external variable I<errno> is "
2434 "set to B<EAGAIN> or B<EWOULDBLOCK>.  The receive calls normally return any "
2435 "data available, up to the requested amount, rather than waiting for receipt "
2436 "of the full amount requested."
2437 msgstr ""
2438
2439 #. type: Plain text
2440 #: build/C/man2/recv.2:129
2441 msgid ""
2442 "The B<select>(2)  or B<poll>(2)  call may be used to determine when more "
2443 "data arrives."
2444 msgstr ""
2445
2446 #. type: Plain text
2447 #: build/C/man2/recv.2:135
2448 msgid ""
2449 "The I<flags> argument to a B<recv>()  call is formed by ORing one or more of "
2450 "the following values:"
2451 msgstr ""
2452
2453 #. type: TP
2454 #: build/C/man2/recv.2:135
2455 #, no-wrap
2456 msgid "B<MSG_CMSG_CLOEXEC> (B<recvmsg>() only; since Linux 2.6.23)"
2457 msgstr ""
2458
2459 #. type: Plain text
2460 #: build/C/man2/recv.2:146
2461 msgid ""
2462 "Set the close-on-exec flag for the file descriptor received via a UNIX "
2463 "domain file descriptor using the B<SCM_RIGHTS> operation (described in "
2464 "B<unix>(7)).  This flag is useful for the same reasons as the B<O_CLOEXEC> "
2465 "flag of B<open>(2)."
2466 msgstr ""
2467
2468 #. type: TP
2469 #: build/C/man2/recv.2:146 build/C/man2/send.2:188
2470 #, no-wrap
2471 msgid "B<MSG_DONTWAIT> (since Linux 2.2)"
2472 msgstr ""
2473
2474 #. type: Plain text
2475 #: build/C/man2/recv.2:156
2476 msgid ""
2477 "Enables nonblocking operation; if the operation would block, the call fails "
2478 "with the error B<EAGAIN> or B<EWOULDBLOCK> (this can also be enabled using "
2479 "the B<O_NONBLOCK> flag with the B<F_SETFL> B<fcntl>(2))."
2480 msgstr ""
2481
2482 #. type: TP
2483 #: build/C/man2/recv.2:156
2484 #, no-wrap
2485 msgid "B<MSG_ERRQUEUE> (since Linux 2.2)"
2486 msgstr ""
2487
2488 #. type: Plain text
2489 #: build/C/man2/recv.2:175
2490 msgid ""
2491 "This flag specifies that queued errors should be received from the socket "
2492 "error queue.  The error is passed in an ancillary message with a type "
2493 "dependent on the protocol (for IPv4 B<IP_RECVERR>).  The user should supply "
2494 "a buffer of sufficient size.  See B<cmsg>(3)  and B<ip>(7)  for more "
2495 "information.  The payload of the original packet that caused the error is "
2496 "passed as normal data via I<msg_iovec>.  The original destination address of "
2497 "the datagram that caused the error is supplied via I<msg_name>."
2498 msgstr ""
2499
2500 #. type: Plain text
2501 #: build/C/man2/recv.2:187 build/C/man2/recv.2:250
2502 msgid ""
2503 "For local errors, no address is passed (this can be checked with the "
2504 "I<cmsg_len> member of the I<cmsghdr>).  For error receives, the "
2505 "B<MSG_ERRQUEUE> is set in the I<msghdr>.  After an error has been passed, "
2506 "the pending socket error is regenerated based on the next queued error and "
2507 "will be passed on the next socket operation."
2508 msgstr ""
2509
2510 #. type: Plain text
2511 #: build/C/man2/recv.2:191
2512 msgid "The error is supplied in a I<sock_extended_err> structure:"
2513 msgstr ""
2514
2515 #. type: Plain text
2516 #: build/C/man2/recv.2:198
2517 #, no-wrap
2518 msgid ""
2519 "#define SO_EE_ORIGIN_NONE    0\n"
2520 "#define SO_EE_ORIGIN_LOCAL   1\n"
2521 "#define SO_EE_ORIGIN_ICMP    2\n"
2522 "#define SO_EE_ORIGIN_ICMP6   3\n"
2523 msgstr ""
2524
2525 #. type: Plain text
2526 #: build/C/man2/recv.2:210
2527 #, no-wrap
2528 msgid ""
2529 "struct sock_extended_err\n"
2530 "{\n"
2531 "    uint32_t ee_errno;   /* error number */\n"
2532 "    uint8_t  ee_origin;  /* where the error originated */\n"
2533 "    uint8_t  ee_type;    /* type */\n"
2534 "    uint8_t  ee_code;    /* code */\n"
2535 "    uint8_t  ee_pad;     /* padding */\n"
2536 "    uint32_t ee_info;    /* additional information */\n"
2537 "    uint32_t ee_data;    /* other data */\n"
2538 "    /* More data may follow */\n"
2539 "};\n"
2540 msgstr ""
2541
2542 #. type: Plain text
2543 #: build/C/man2/recv.2:212
2544 #, no-wrap
2545 msgid "struct sockaddr *SO_EE_OFFENDER(struct sock_extended_err *);\n"
2546 msgstr ""
2547
2548 #. type: Plain text
2549 #: build/C/man2/recv.2:236
2550 msgid ""
2551 "I<ee_errno> contains the I<errno> number of the queued error.  I<ee_origin> "
2552 "is the origin code of where the error originated.  The other fields are "
2553 "protocol-specific.  The macro B<SOCK_EE_OFFENDER> returns a pointer to the "
2554 "address of the network object where the error originated from given a "
2555 "pointer to the ancillary message.  If this address is not known, the "
2556 "I<sa_family> member of the I<sockaddr> contains B<AF_UNSPEC> and the other "
2557 "fields of the I<sockaddr> are undefined.  The payload of the packet that "
2558 "caused the error is passed as normal data."
2559 msgstr ""
2560
2561 #. type: TP
2562 #: build/C/man2/recv.2:250 build/C/man2/recv.2:381 build/C/man2/send.2:230
2563 #, no-wrap
2564 msgid "B<MSG_OOB>"
2565 msgstr ""
2566
2567 #. type: Plain text
2568 #: build/C/man2/recv.2:257
2569 msgid ""
2570 "This flag requests receipt of out-of-band data that would not be received in "
2571 "the normal data stream.  Some protocols place expedited data at the head of "
2572 "the normal data queue, and thus this flag cannot be used with such "
2573 "protocols."
2574 msgstr ""
2575
2576 #. type: TP
2577 #: build/C/man2/recv.2:257
2578 #, no-wrap
2579 msgid "B<MSG_PEEK>"
2580 msgstr ""
2581
2582 #. type: Plain text
2583 #: build/C/man2/recv.2:264
2584 msgid ""
2585 "This flag causes the receive operation to return data from the beginning of "
2586 "the receive queue without removing that data from the queue.  Thus, a "
2587 "subsequent receive call will return the same data."
2588 msgstr ""
2589
2590 #. type: TP
2591 #: build/C/man2/recv.2:264
2592 #, no-wrap
2593 msgid "B<MSG_TRUNC> (since Linux 2.2)"
2594 msgstr ""
2595
2596 #. type: Plain text
2597 #: build/C/man2/recv.2:275
2598 msgid ""
2599 "For raw (B<AF_PACKET>), Internet datagram (since Linux 2.4.27/2.6.8), "
2600 "netlink (since Linux 2.6.22) and UNIX datagram (since Linux 3.4) sockets: "
2601 "return the real length of the packet or datagram, even when it was longer "
2602 "than the passed buffer.  Not implemented for UNIX domain (B<unix>(7))  "
2603 "sockets."
2604 msgstr ""
2605
2606 #. type: Plain text
2607 #: build/C/man2/recv.2:278
2608 msgid "For use with Internet stream sockets, see B<tcp>(7)."
2609 msgstr ""
2610
2611 #. type: TP
2612 #: build/C/man2/recv.2:278
2613 #, no-wrap
2614 msgid "B<MSG_WAITALL> (since Linux 2.2)"
2615 msgstr ""
2616
2617 #. type: Plain text
2618 #: build/C/man2/recv.2:285
2619 msgid ""
2620 "This flag requests that the operation block until the full request is "
2621 "satisfied.  However, the call may still return less data than requested if a "
2622 "signal is caught, an error or disconnect occurs, or the next data to be "
2623 "received is of a different type than that returned."
2624 msgstr ""
2625
2626 #. type: Plain text
2627 #: build/C/man2/recv.2:293
2628 msgid ""
2629 "The B<recvmsg>()  call uses a I<msghdr> structure to minimize the number of "
2630 "directly supplied arguments.  This structure is defined as follows in "
2631 "I<E<lt>sys/socket.hE<gt>>:"
2632 msgstr ""
2633
2634 #. type: Plain text
2635 #: build/C/man2/recv.2:300
2636 #, no-wrap
2637 msgid ""
2638 "struct iovec {                    /* Scatter/gather array items */\n"
2639 "    void  *iov_base;              /* Starting address */\n"
2640 "    size_t iov_len;               /* Number of bytes to transfer */\n"
2641 "};\n"
2642 msgstr ""
2643
2644 #. type: Plain text
2645 #: build/C/man2/recv.2:310 build/C/man2/send.2:258
2646 #, no-wrap
2647 msgid ""
2648 "struct msghdr {\n"
2649 "    void         *msg_name;       /* optional address */\n"
2650 "    socklen_t     msg_namelen;    /* size of address */\n"
2651 "    struct iovec *msg_iov;        /* scatter/gather array */\n"
2652 "    size_t        msg_iovlen;     /* # elements in msg_iov */\n"
2653 "    void         *msg_control;    /* ancillary data, see below */\n"
2654 "    size_t        msg_controllen; /* ancillary data buffer len */\n"
2655 "    int           msg_flags;      /* flags on received message */\n"
2656 "};\n"
2657 msgstr ""
2658
2659 #. type: Plain text
2660 #: build/C/man2/recv.2:340
2661 msgid ""
2662 "Here I<msg_name> and I<msg_namelen> specify the source address if the socket "
2663 "is unconnected; I<msg_name> may be given as a NULL pointer if no names are "
2664 "desired or required.  The fields I<msg_iov> and I<msg_iovlen> describe "
2665 "scatter-gather locations, as discussed in B<readv>(2).  The field "
2666 "I<msg_control>, which has length I<msg_controllen>, points to a buffer for "
2667 "other protocol control-related messages or miscellaneous ancillary data.  "
2668 "When B<recvmsg>()  is called, I<msg_controllen> should contain the length of "
2669 "the available buffer in I<msg_control>; upon return from a successful call "
2670 "it will contain the length of the control message sequence."
2671 msgstr ""
2672
2673 #. type: Plain text
2674 #: build/C/man2/recv.2:342
2675 msgid "The messages are of the form:"
2676 msgstr ""
2677
2678 #. type: Plain text
2679 #: build/C/man2/recv.2:352
2680 #, no-wrap
2681 msgid ""
2682 "struct cmsghdr {\n"
2683 "    socklen_t     cmsg_len;     /* data byte count, including hdr */\n"
2684 "    int           cmsg_level;   /* originating protocol */\n"
2685 "    int           cmsg_type;    /* protocol-specific type */\n"
2686 "/* followed by\n"
2687 "    unsigned char cmsg_data[]; */\n"
2688 "};\n"
2689 msgstr ""
2690
2691 #. type: Plain text
2692 #: build/C/man2/recv.2:357
2693 msgid "Ancillary data should only be accessed by the macros defined in B<cmsg>(3)."
2694 msgstr ""
2695
2696 #. type: Plain text
2697 #: build/C/man2/recv.2:360
2698 msgid ""
2699 "As an example, Linux uses this ancillary data mechanism to pass extended "
2700 "errors, IP options, or file descriptors over UNIX domain sockets."
2701 msgstr ""
2702
2703 #. type: Plain text
2704 #: build/C/man2/recv.2:368
2705 msgid ""
2706 "The I<msg_flags> field in the I<msghdr> is set on return of B<recvmsg>().  "
2707 "It can contain several flags:"
2708 msgstr ""
2709
2710 #. type: TP
2711 #: build/C/man2/recv.2:368
2712 #, no-wrap
2713 msgid "B<MSG_EOR>"
2714 msgstr ""
2715
2716 #. type: Plain text
2717 #: build/C/man2/recv.2:373
2718 msgid ""
2719 "indicates end-of-record; the data returned completed a record (generally "
2720 "used with sockets of type B<SOCK_SEQPACKET>)."
2721 msgstr ""
2722
2723 #. type: TP
2724 #: build/C/man2/recv.2:373
2725 #, no-wrap
2726 msgid "B<MSG_TRUNC>"
2727 msgstr ""
2728
2729 #. type: Plain text
2730 #: build/C/man2/recv.2:377
2731 msgid ""
2732 "indicates that the trailing portion of a datagram was discarded because the "
2733 "datagram was larger than the buffer supplied."
2734 msgstr ""
2735
2736 #. type: TP
2737 #: build/C/man2/recv.2:377
2738 #, no-wrap
2739 msgid "B<MSG_CTRUNC>"
2740 msgstr ""
2741
2742 #. type: Plain text
2743 #: build/C/man2/recv.2:381
2744 msgid ""
2745 "indicates that some control data were discarded due to lack of space in the "
2746 "buffer for ancillary data."
2747 msgstr ""
2748
2749 #. type: Plain text
2750 #: build/C/man2/recv.2:384
2751 msgid "is returned to indicate that expedited or out-of-band data were received."
2752 msgstr ""
2753
2754 #. type: TP
2755 #: build/C/man2/recv.2:384
2756 #, no-wrap
2757 msgid "B<MSG_ERRQUEUE>"
2758 msgstr ""
2759
2760 #. type: Plain text
2761 #: build/C/man2/recv.2:388
2762 msgid ""
2763 "indicates that no data was received but an extended error from the socket "
2764 "error queue."
2765 msgstr ""
2766
2767 #. type: Plain text
2768 #: build/C/man2/recv.2:393
2769 msgid ""
2770 "These calls return the number of bytes received, or -1 if an error "
2771 "occurred.  The return value will be 0 when the peer has performed an orderly "
2772 "shutdown."
2773 msgstr ""
2774
2775 #. type: Plain text
2776 #: build/C/man2/recv.2:398
2777 msgid ""
2778 "These are some standard errors generated by the socket layer.  Additional "
2779 "errors may be generated and returned from the underlying protocol modules; "
2780 "see their manual pages."
2781 msgstr ""
2782
2783 #.  Actually EAGAIN on Linux
2784 #. type: Plain text
2785 #: build/C/man2/recv.2:407
2786 msgid ""
2787 "The socket is marked nonblocking and the receive operation would block, or a "
2788 "receive timeout had been set and the timeout expired before data was "
2789 "received.  POSIX.1-2001 allows either error to be returned for this case, "
2790 "and does not require these constants to have the same value, so a portable "
2791 "application should check for both possibilities."
2792 msgstr ""
2793
2794 #. type: Plain text
2795 #: build/C/man2/recv.2:412
2796 msgid "The argument I<sockfd> is an invalid descriptor."
2797 msgstr ""
2798
2799 #. type: Plain text
2800 #: build/C/man2/recv.2:416
2801 msgid ""
2802 "A remote host refused to allow the network connection (typically because it "
2803 "is not running the requested service)."
2804 msgstr ""
2805
2806 #. type: Plain text
2807 #: build/C/man2/recv.2:420
2808 msgid "The receive buffer pointer(s) point outside the process's address space."
2809 msgstr ""
2810
2811 #. type: Plain text
2812 #: build/C/man2/recv.2:425
2813 msgid ""
2814 "The receive was interrupted by delivery of a signal before any data were "
2815 "available; see B<signal>(7)."
2816 msgstr ""
2817
2818 #. type: Plain text
2819 #: build/C/man2/recv.2:429 build/C/man2/send.2:323
2820 msgid "Invalid argument passed."
2821 msgstr ""
2822
2823 #. type: Plain text
2824 #: build/C/man2/recv.2:433
2825 msgid "Could not allocate memory for B<recvmsg>()."
2826 msgstr ""
2827
2828 #. type: TP
2829 #: build/C/man2/recv.2:433 build/C/man2/send.2:346
2830 #, no-wrap
2831 msgid "B<ENOTCONN>"
2832 msgstr ""
2833
2834 #. type: Plain text
2835 #: build/C/man2/recv.2:440
2836 msgid ""
2837 "The socket is associated with a connection-oriented protocol and has not "
2838 "been connected (see B<connect>(2)  and B<accept>(2))."
2839 msgstr ""
2840
2841 #. type: Plain text
2842 #: build/C/man2/recv.2:445
2843 msgid "The argument I<sockfd> does not refer to a socket."
2844 msgstr ""
2845
2846 #. type: Plain text
2847 #: build/C/man2/recv.2:448
2848 msgid "4.4BSD (these function calls first appeared in 4.2BSD), POSIX.1-2001."
2849 msgstr ""
2850
2851 #. type: Plain text
2852 #: build/C/man2/recv.2:455
2853 msgid ""
2854 "POSIX.1-2001 only describes the B<MSG_OOB>, B<MSG_PEEK>, and B<MSG_WAITALL> "
2855 "flags."
2856 msgstr ""
2857
2858 #. type: Plain text
2859 #: build/C/man2/recv.2:471
2860 msgid ""
2861 "The prototypes given above follow glibc2.  The Single UNIX Specification "
2862 "agrees, except that it has return values of type I<ssize_t> (while 4.x BSD "
2863 "and libc4 and libc5 all have I<int>).  The I<flags> argument is I<int> in "
2864 "4.x BSD, but I<unsigned int> in libc4 and libc5.  The I<len> argument is "
2865 "I<int> in 4.x BSD, but I<size_t> in libc4 and libc5.  The I<addrlen> "
2866 "argument is I<int\\ *> in 4.x BSD, libc4 and libc5.  The present "
2867 "I<socklen_t\\ *> was invented by POSIX.  See also B<accept>(2)."
2868 msgstr ""
2869
2870 #.  glibc bug raised 12 Mar 2006
2871 #.  http://sourceware.org/bugzilla/show_bug.cgi?id=2448
2872 #.  The problem is an underlying kernel issue: the size of the
2873 #.  __kernel_size_t type used to type this field varies
2874 #.  across architectures, but socklen_t is always 32 bits.
2875 #. type: Plain text
2876 #: build/C/man2/recv.2:485 build/C/man2/send.2:409
2877 msgid ""
2878 "According to POSIX.1-2001, the I<msg_controllen> field of the I<msghdr> "
2879 "structure should be typed as I<socklen_t>, but glibc currently types it as "
2880 "I<size_t>."
2881 msgstr ""
2882
2883 #. type: Plain text
2884 #: build/C/man2/recv.2:490
2885 msgid ""
2886 "See B<recvmmsg>(2)  for information about a Linux-specific system call that "
2887 "can be used to receive multiple datagrams in a single call."
2888 msgstr ""
2889
2890 #. type: Plain text
2891 #: build/C/man2/recv.2:495
2892 msgid "An example of the use of B<recvfrom>()  is shown in B<getaddrinfo>(3)."
2893 msgstr ""
2894
2895 #. type: Plain text
2896 #: build/C/man2/recv.2:506
2897 msgid ""
2898 "B<fcntl>(2), B<getsockopt>(2), B<read>(2), B<recvmmsg>(2), B<select>(2), "
2899 "B<shutdown>(2), B<socket>(2), B<cmsg>(3), B<sockatmark>(3), B<socket>(7)"
2900 msgstr ""
2901
2902 #. type: TH
2903 #: build/C/man2/recvmmsg.2:31
2904 #, no-wrap
2905 msgid "RECVMMSG"
2906 msgstr ""
2907
2908 #. type: TH
2909 #: build/C/man2/recvmmsg.2:31
2910 #, no-wrap
2911 msgid "2012-12-24"
2912 msgstr ""
2913
2914 #. type: Plain text
2915 #: build/C/man2/recvmmsg.2:34
2916 msgid "recvmmsg - receive multiple messages on a socket"
2917 msgstr ""
2918
2919 #. type: Plain text
2920 #: build/C/man2/recvmmsg.2:38 build/C/man2/sendmmsg.2:35
2921 #, no-wrap
2922 msgid ""
2923 "B<#define _GNU_SOURCE>\n"
2924 "B<#include E<lt>sys/socket.hE<gt>>\n"
2925 msgstr ""
2926
2927 #. type: Plain text
2928 #: build/C/man2/recvmmsg.2:41
2929 #, no-wrap
2930 msgid ""
2931 "B<int recvmmsg(int >I<sockfd>B<, struct mmsghdr *>I<msgvec>B<, unsigned int "
2932 ">I<vlen>B<,>\n"
2933 msgstr ""
2934
2935 #. type: Plain text
2936 #: build/C/man2/recvmmsg.2:43
2937 #, no-wrap
2938 msgid "B<             unsigned int >I<flags>B<, struct timespec *>I<timeout>B<);>\n"
2939 msgstr ""
2940
2941 #. type: Plain text
2942 #: build/C/man2/recvmmsg.2:55
2943 msgid ""
2944 "The B<recvmmsg>()  system call is an extension of B<recvmsg>(2)  that allows "
2945 "the caller to receive multiple messages from a socket using a single system "
2946 "call.  (This has performance benefits for some applications.)  A further "
2947 "extension over B<recvmsg>(2)  is support for a timeout on the receive "
2948 "operation."
2949 msgstr ""
2950
2951 #. type: Plain text
2952 #: build/C/man2/recvmmsg.2:59
2953 msgid ""
2954 "The I<sockfd> argument is the file descriptor of the socket to receive data "
2955 "from."
2956 msgstr ""
2957
2958 #. type: Plain text
2959 #: build/C/man2/recvmmsg.2:67 build/C/man2/sendmmsg.2:62
2960 msgid ""
2961 "The I<msgvec> argument is a pointer to an array of I<mmsghdr> structures.  "
2962 "The size of this array is specified in I<vlen>."
2963 msgstr ""
2964
2965 #. type: Plain text
2966 #: build/C/man2/recvmmsg.2:73 build/C/man2/sendmmsg.2:68
2967 msgid "The I<mmsghdr> structure is defined in I<E<lt>sys/socket.hE<gt>> as:"
2968 msgstr ""
2969
2970 #. type: Plain text
2971 #: build/C/man2/recvmmsg.2:80
2972 #, no-wrap
2973 msgid ""
2974 "struct mmsghdr {\n"
2975 "    struct msghdr msg_hdr;  /* Message header */\n"
2976 "    unsigned int  msg_len;  /* Number of received bytes for header */\n"
2977 "};\n"
2978 msgstr ""
2979
2980 #. type: Plain text
2981 #: build/C/man2/recvmmsg.2:95
2982 msgid ""
2983 "The I<msg_hdr> field is a I<msghdr> structure, as described in "
2984 "B<recvmsg>(2).  The I<msg_len> field is the number of bytes returned for the "
2985 "message in the entry.  This field has the same value as the return value of "
2986 "a single B<recvmsg>(2)  on the header."
2987 msgstr ""
2988
2989 #. type: Plain text
2990 #: build/C/man2/recvmmsg.2:102
2991 msgid ""
2992 "The I<flags> argument contains flags ORed together.  The flags are the same "
2993 "as documented for B<recvmsg>(2), with the following addition:"
2994 msgstr ""
2995
2996 #. type: TP
2997 #: build/C/man2/recvmmsg.2:102
2998 #, no-wrap
2999 msgid "B<MSG_WAITFORONE> (since Linux 2.6.34)"
3000 msgstr ""
3001
3002 #. type: Plain text
3003 #: build/C/man2/recvmmsg.2:107
3004 msgid "Turns on B<MSG_DONTWAIT> after the first message has been received."
3005 msgstr ""
3006
3007 #. type: Plain text
3008 #: build/C/man2/recvmmsg.2:123
3009 msgid ""
3010 "The I<timeout> argument points to a I<struct timespec> (see "
3011 "B<clock_gettime>(2))  defining a timeout (seconds plus nanoseconds) for the "
3012 "receive operation.  (This interval will be rounded up to the system clock "
3013 "granularity, and kernel scheduling delays mean that the blocking interval "
3014 "may overrun by a small amount.)  If I<timeout> is I<NULL> then the operation "
3015 "blocks indefinitely."
3016 msgstr ""
3017
3018 #. type: Plain text
3019 #: build/C/man2/recvmmsg.2:134
3020 msgid ""
3021 "A blocking B<recvmmsg>()  call blocks until I<vlen> messages have been "
3022 "received or until the timeout expires.  A nonblocking call reads as many "
3023 "messages as are available (up to the limit specified by I<vlen>)  and "
3024 "returns immediately."
3025 msgstr ""
3026
3027 #. type: Plain text
3028 #: build/C/man2/recvmmsg.2:149
3029 msgid ""
3030 "On return from B<recvmmsg>(), successive elements of I<msgvec> are updated "
3031 "to contain information about each received message: I<msg_len> contains the "
3032 "size of the received message; the subfields of I<msg_hdr> are updated as "
3033 "described in B<recvmsg>(2).  The return value of the call indicates the "
3034 "number of elements of I<msgvec> that have been updated."
3035 msgstr ""
3036
3037 #. type: Plain text
3038 #: build/C/man2/recvmmsg.2:157
3039 msgid ""
3040 "On success, B<recvmmsg>()  returns the number of messages received in "
3041 "I<msgvec>; on error, -1 is returned, and I<errno> is set to indicate the "
3042 "error."
3043 msgstr ""
3044
3045 #. type: Plain text
3046 #: build/C/man2/recvmmsg.2:161
3047 msgid ""
3048 "Errors are as for B<recvmsg>(2).  In addition, the following error can "
3049 "occur:"
3050 msgstr ""
3051
3052 #. type: Plain text
3053 #: build/C/man2/recvmmsg.2:165
3054 msgid "I<timeout> is invalid."
3055 msgstr ""
3056
3057 #. type: Plain text
3058 #: build/C/man2/recvmmsg.2:170
3059 msgid ""
3060 "The B<recvmmsg>()  system call was added in Linux 2.6.33.  Support in glibc "
3061 "was added in version 2.12."
3062 msgstr ""
3063
3064 #. type: Plain text
3065 #: build/C/man2/recvmmsg.2:173
3066 msgid "B<recvmmsg>()  is Linux-specific."
3067 msgstr ""
3068
3069 #. type: Plain text
3070 #: build/C/man2/recvmmsg.2:181
3071 msgid ""
3072 "The following program uses B<recvmmsg>()  to receive multiple messages on a "
3073 "socket and stores them in multiple buffers.  The call returns if all buffers "
3074 "are filled or if the timeout specified has expired."
3075 msgstr ""
3076
3077 #. type: Plain text
3078 #: build/C/man2/recvmmsg.2:184
3079 msgid ""
3080 "The following snippet periodically generates UDP datagrams containing a "
3081 "random number:"
3082 msgstr ""
3083
3084 #. type: Plain text
3085 #: build/C/man2/recvmmsg.2:189
3086 #, no-wrap
3087 msgid ""
3088 "$B< while true; do echo $RANDOM E<gt> /dev/udp/127.0.0.1/1234; >\n"
3089 "B<sleep 0.25; done>\n"
3090 msgstr ""
3091
3092 #. type: Plain text
3093 #: build/C/man2/recvmmsg.2:194
3094 msgid ""
3095 "These datagrams are read by the example application, which can give the "
3096 "following output:"
3097 msgstr ""
3098
3099 #. type: Plain text
3100 #: build/C/man2/recvmmsg.2:204
3101 #, no-wrap
3102 msgid ""
3103 "$B< ./a.out>\n"
3104 "5 messages received\n"
3105 "1 11782\n"
3106 "2 11345\n"
3107 "3 304\n"
3108 "4 13514\n"
3109 "5 28421\n"
3110 msgstr ""
3111
3112 #. type: Plain text
3113 #: build/C/man2/recvmmsg.2:215
3114 #, no-wrap
3115 msgid ""
3116 "#define _GNU_SOURCE\n"
3117 "#include E<lt>netinet/ip.hE<gt>\n"
3118 "#include E<lt>stdio.hE<gt>\n"
3119 "#include E<lt>stdlib.hE<gt>\n"
3120 "#include E<lt>string.hE<gt>\n"
3121 "#include E<lt>sys/socket.hE<gt>\n"
3122 msgstr ""
3123
3124 #. type: Plain text
3125 #: build/C/man2/recvmmsg.2:228
3126 #, no-wrap
3127 msgid ""
3128 "int\n"
3129 "main(void)\n"
3130 "{\n"
3131 "#define VLEN 10\n"
3132 "#define BUFSIZE 200\n"
3133 "#define TIMEOUT 1\n"
3134 "    int sockfd, retval, i;\n"
3135 "    struct sockaddr_in sa;\n"
3136 "    struct mmsghdr msgs[VLEN];\n"
3137 "    struct iovec iovecs[VLEN];\n"
3138 "    char bufs[VLEN][BUFSIZE+1];\n"
3139 "    struct timespec timeout;\n"
3140 msgstr ""
3141
3142 #. type: Plain text
3143 #: build/C/man2/recvmmsg.2:234 build/C/man2/sendmmsg.2:201
3144 #, no-wrap
3145 msgid ""
3146 "    sockfd = socket(AF_INET, SOCK_DGRAM, 0);\n"
3147 "    if (sockfd == -1) {\n"
3148 "        perror(\"socket()\");\n"
3149 "        exit(EXIT_FAILURE);\n"
3150 "    }\n"
3151 msgstr ""
3152
3153 #. type: Plain text
3154 #: build/C/man2/recvmmsg.2:242
3155 #, no-wrap
3156 msgid ""
3157 "    sa.sin_family = AF_INET;\n"
3158 "    sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK);\n"
3159 "    sa.sin_port = htons(1234);\n"
3160 "    if (bind(sockfd, (struct sockaddr *) &sa, sizeof(sa)) == -1) {\n"
3161 "        perror(\"bind()\");\n"
3162 "        exit(EXIT_FAILURE);\n"
3163 "    }\n"
3164 msgstr ""
3165
3166 #. type: Plain text
3167 #: build/C/man2/recvmmsg.2:250
3168 #, no-wrap
3169 msgid ""
3170 "    memset(msgs, 0, sizeof(msgs));\n"
3171 "    for (i = 0; i E<lt> VLEN; i++) {\n"
3172 "        iovecs[i].iov_base         = bufs[i];\n"
3173 "        iovecs[i].iov_len          = BUFSIZE;\n"
3174 "        msgs[i].msg_hdr.msg_iov    = &iovecs[i];\n"
3175 "        msgs[i].msg_hdr.msg_iovlen = 1;\n"
3176 "    }\n"
3177 msgstr ""
3178
3179 #. type: Plain text
3180 #: build/C/man2/recvmmsg.2:253
3181 #, no-wrap
3182 msgid ""
3183 "    timeout.tv_sec = TIMEOUT;\n"
3184 "    timeout.tv_nsec = 0;\n"
3185 msgstr ""
3186
3187 #. type: Plain text
3188 #: build/C/man2/recvmmsg.2:259
3189 #, no-wrap
3190 msgid ""
3191 "    retval = recvmmsg(sockfd, msgs, VLEN, 0, &timeout);\n"
3192 "    if (retval == -1) {\n"
3193 "        perror(\"recvmmsg()\");\n"
3194 "        exit(EXIT_FAILURE);\n"
3195 "    }\n"
3196 msgstr ""
3197
3198 #. type: Plain text
3199 #: build/C/man2/recvmmsg.2:267
3200 #, no-wrap
3201 msgid ""
3202 "    printf(\"%d messages received\\en\", retval);\n"
3203 "    for (i = 0; i E<lt> retval; i++) {\n"
3204 "        bufs[i][msgs[i].msg_len] = 0;\n"
3205 "        printf(\"%d %s\", i+1, bufs[i]);\n"
3206 "    }\n"
3207 "    exit(EXIT_SUCCESS);\n"
3208 "}\n"
3209 msgstr ""
3210
3211 #. type: Plain text
3212 #: build/C/man2/recvmmsg.2:275
3213 msgid ""
3214 "B<clock_gettime>(2), B<recvmsg>(2), B<sendmmsg>(2), B<sendmsg>(2), "
3215 "B<socket>(2), B<socket>(7)"
3216 msgstr ""
3217
3218 #. type: TH
3219 #: build/C/man2/select.2:38
3220 #, no-wrap
3221 msgid "SELECT"
3222 msgstr ""
3223
3224 #. type: TH
3225 #: build/C/man2/select.2:38
3226 #, no-wrap
3227 msgid "2012-08-17"
3228 msgstr ""
3229
3230 #. type: Plain text
3231 #: build/C/man2/select.2:42 build/C/man2/select_tut.2:36
3232 msgid ""
3233 "select, pselect, FD_CLR, FD_ISSET, FD_SET, FD_ZERO - synchronous I/O "
3234 "multiplexing"
3235 msgstr ""
3236
3237 #. type: Plain text
3238 #: build/C/man2/select.2:45 build/C/man2/select_tut.2:39
3239 #, no-wrap
3240 msgid "/* According to POSIX.1-2001 */\n"
3241 msgstr ""
3242
3243 #. type: Plain text
3244 #: build/C/man2/select.2:47 build/C/man2/select.2:68 build/C/man2/select_tut.2:41 build/C/man2/select_tut.2:62
3245 #, no-wrap
3246 msgid "B<#include E<lt>sys/select.hE<gt>>\n"
3247 msgstr ""
3248
3249 #. type: Plain text
3250 #: build/C/man2/select.2:49 build/C/man2/select_tut.2:43
3251 #, no-wrap
3252 msgid "/* According to earlier standards */\n"
3253 msgstr ""
3254
3255 #. type: Plain text
3256 #: build/C/man2/select.2:51 build/C/man2/select_tut.2:45
3257 #, no-wrap
3258 msgid "B<#include E<lt>sys/time.hE<gt>>\n"
3259 msgstr ""
3260
3261 #. type: Plain text
3262 #: build/C/man2/select.2:55 build/C/man2/select_tut.2:49
3263 #, no-wrap
3264 msgid "B<#include E<lt>unistd.hE<gt>>\n"
3265 msgstr ""
3266
3267 #. type: Plain text
3268 #: build/C/man2/select.2:58
3269 #, no-wrap
3270 msgid ""
3271 "B<int select(int >I<nfds>B<, fd_set *>I<readfds>B<, fd_set "
3272 "*>I<writefds>B<,>\n"
3273 "B<           fd_set *>I<exceptfds>B<, struct timeval *>I<timeout>B<);>\n"
3274 msgstr ""
3275
3276 #. type: Plain text
3277 #: build/C/man2/select.2:60 build/C/man2/select_tut.2:54
3278 #, no-wrap
3279 msgid "B<void FD_CLR(int >I<fd>B<, fd_set *>I<set>B<);>\n"
3280 msgstr ""
3281
3282 #. type: Plain text
3283 #: build/C/man2/select.2:62 build/C/man2/select_tut.2:56
3284 #, no-wrap
3285 msgid "B<int  FD_ISSET(int >I<fd>B<, fd_set *>I<set>B<);>\n"
3286 msgstr ""
3287
3288 #. type: Plain text
3289 #: build/C/man2/select.2:64 build/C/man2/select_tut.2:58
3290 #, no-wrap
3291 msgid "B<void FD_SET(int >I<fd>B<, fd_set *>I<set>B<);>\n"
3292 msgstr ""
3293
3294 #. type: Plain text
3295 #: build/C/man2/select.2:66 build/C/man2/select_tut.2:60
3296 #, no-wrap
3297 msgid "B<void FD_ZERO(fd_set *>I<set>B<);>\n"
3298 msgstr ""
3299
3300 #. type: Plain text
3301 #: build/C/man2/select.2:72
3302 #, no-wrap
3303 msgid ""
3304 "B<int pselect(int >I<nfds>B<, fd_set *>I<readfds>B<, fd_set "
3305 "*>I<writefds>B<,>\n"
3306 "B<            fd_set *>I<exceptfds>B<, const struct timespec "
3307 "*>I<timeout>B<,>\n"
3308 "B<            const sigset_t *>I<sigmask>B<);>\n"
3309 msgstr ""
3310
3311 #. type: Plain text
3312 #: build/C/man2/select.2:77 build/C/man2/select_tut.2:71 build/C/man3/sockatmark.3:36
3313 msgid "Feature Test Macro Requirements for glibc (see B<feature_test_macros>(7)):"
3314 msgstr ""
3315
3316 #. type: Plain text
3317 #: build/C/man2/select.2:81 build/C/man2/select_tut.2:75
3318 msgid ""
3319 "B<pselect>(): _POSIX_C_SOURCE\\ E<gt>=\\ 200112L || _XOPEN_SOURCE\\ E<gt>=\\ "
3320 "600"
3321 msgstr ""
3322
3323 #. type: Plain text
3324 #: build/C/man2/select.2:92
3325 msgid ""
3326 "B<select>()  and B<pselect>()  allow a program to monitor multiple file "
3327 "descriptors, waiting until one or more of the file descriptors become "
3328 "\"ready\" for some class of I/O operation (e.g., input possible).  A file "
3329 "descriptor is considered ready if it is possible to perform the "
3330 "corresponding I/O operation (e.g., B<read>(2))  without blocking."
3331 msgstr ""
3332
3333 #. type: Plain text
3334 #: build/C/man2/select.2:98
3335 msgid ""
3336 "The operation of B<select>()  and B<pselect>()  is identical, other than "
3337 "these three differences:"
3338 msgstr ""
3339
3340 #. type: TP
3341 #: build/C/man2/select.2:98
3342 #, no-wrap
3343 msgid "(i)"
3344 msgstr ""
3345
3346 #. type: Plain text
3347 #: build/C/man2/select.2:108
3348 msgid ""
3349 "B<select>()  uses a timeout that is a I<struct timeval> (with seconds and "
3350 "microseconds), while B<pselect>()  uses a I<struct timespec> (with seconds "
3351 "and nanoseconds)."
3352 msgstr ""
3353
3354 #. type: TP
3355 #: build/C/man2/select.2:108
3356 #, no-wrap
3357 msgid "(ii)"
3358 msgstr ""
3359
3360 #. type: Plain text
3361 #: build/C/man2/select.2:116
3362 msgid ""
3363 "B<select>()  may update the I<timeout> argument to indicate how much time "
3364 "was left.  B<pselect>()  does not change this argument."
3365 msgstr ""
3366
3367 #. type: TP
3368 #: build/C/man2/select.2:116
3369 #, no-wrap
3370 msgid "(iii)"
3371 msgstr ""
3372
3373 #. type: Plain text
3374 #: build/C/man2/select.2:125
3375 msgid ""
3376 "B<select>()  has no I<sigmask> argument, and behaves as B<pselect>()  called "
3377 "with NULL I<sigmask>."
3378 msgstr ""
3379
3380 #. type: Plain text
3381 #: build/C/man2/select.2:143
3382 msgid ""
3383 "Three independent sets of file descriptors are watched.  Those listed in "
3384 "I<readfds> will be watched to see if characters become available for reading "
3385 "(more precisely, to see if a read will not block; in particular, a file "
3386 "descriptor is also ready on end-of-file), those in I<writefds> will be "
3387 "watched to see if a write will not block, and those in I<exceptfds> will be "
3388 "watched for exceptions.  On exit, the sets are modified in place to indicate "
3389 "which file descriptors actually changed status.  Each of the three file "
3390 "descriptor sets may be specified as NULL if no file descriptors are to be "
3391 "watched for the corresponding class of events."
3392 msgstr ""
3393
3394 #. type: Plain text
3395 #: build/C/man2/select.2:156
3396 msgid ""
3397 "Four macros are provided to manipulate the sets.  B<FD_ZERO>()  clears a "
3398 "set.  B<FD_SET>()  and B<FD_CLR>()  respectively add and remove a given file "
3399 "descriptor from a set.  B<FD_ISSET>()  tests to see if a file descriptor is "
3400 "part of the set; this is useful after B<select>()  returns."
3401 msgstr ""
3402
3403 #. type: Plain text
3404 #: build/C/man2/select.2:159
3405 msgid ""
3406 "I<nfds> is the highest-numbered file descriptor in any of the three sets, "
3407 "plus 1."
3408 msgstr ""
3409
3410 #. type: Plain text
3411 #: build/C/man2/select.2:179
3412 msgid ""
3413 "The I<timeout> argument specifies the minimum interval that B<select>()  "
3414 "should block waiting for a file descriptor to become ready.  (This interval "
3415 "will be rounded up to the system clock granularity, and kernel scheduling "
3416 "delays mean that the blocking interval may overrun by a small amount.)  If "
3417 "both fields of the I<timeval> structure are zero, then B<select>()  returns "
3418 "immediately.  (This is useful for polling.)  If I<timeout> is NULL (no "
3419 "timeout), B<select>()  can block indefinitely."
3420 msgstr ""
3421
3422 #. type: Plain text
3423 #: build/C/man2/select.2:189
3424 msgid ""
3425 "I<sigmask> is a pointer to a signal mask (see B<sigprocmask>(2)); if it is "
3426 "not NULL, then B<pselect>()  first replaces the current signal mask by the "
3427 "one pointed to by I<sigmask>, then does the \"select\" function, and then "
3428 "restores the original signal mask."
3429 msgstr ""
3430
3431 #. type: Plain text
3432 #: build/C/man2/select.2:195
3433 msgid ""
3434 "Other than the difference in the precision of the I<timeout> argument, the "
3435 "following B<pselect>()  call:"
3436 msgstr ""
3437
3438 #. type: Plain text
3439 #: build/C/man2/select.2:199
3440 #, no-wrap
3441 msgid ""
3442 "    ready = pselect(nfds, &readfds, &writefds, &exceptfds,\n"
3443 "                    timeout, &sigmask);\n"
3444 msgstr ""
3445
3446 #. type: Plain text
3447 #: build/C/man2/select.2:204
3448 msgid "is equivalent to I<atomically> executing the following calls:"
3449 msgstr ""
3450
3451 #. type: Plain text
3452 #: build/C/man2/select.2:207
3453 #, no-wrap
3454 msgid "    sigset_t origmask;\n"
3455 msgstr ""
3456
3457 #. type: Plain text
3458 #: build/C/man2/select.2:211
3459 #, no-wrap
3460 msgid ""
3461 "    pthread_sigmask(SIG_SETMASK, &sigmask, &origmask);\n"
3462 "    ready = select(nfds, &readfds, &writefds, &exceptfds, timeout);\n"
3463 "    pthread_sigmask(SIG_SETMASK, &origmask, NULL);\n"
3464 msgstr ""
3465
3466 #. type: Plain text
3467 #: build/C/man2/select.2:232
3468 msgid ""
3469 "The reason that B<pselect>()  is needed is that if one wants to wait for "
3470 "either a signal or for a file descriptor to become ready, then an atomic "
3471 "test is needed to prevent race conditions.  (Suppose the signal handler sets "
3472 "a global flag and returns.  Then a test of this global flag followed by a "
3473 "call of B<select>()  could hang indefinitely if the signal arrived just "
3474 "after the test but just before the call.  By contrast, B<pselect>()  allows "
3475 "one to first block signals, handle the signals that have come in, then call "
3476 "B<pselect>()  with the desired I<sigmask>, avoiding the race.)"
3477 msgstr ""
3478
3479 #. type: SS
3480 #: build/C/man2/select.2:232
3481 #, no-wrap
3482 msgid "The timeout"
3483 msgstr ""
3484
3485 #. type: Plain text
3486 #: build/C/man2/select.2:236
3487 msgid ""
3488 "The time structures involved are defined in I<E<lt>sys/time.hE<gt>> and look "
3489 "like"
3490 msgstr ""
3491
3492 #. type: Plain text
3493 #: build/C/man2/select.2:243
3494 #, no-wrap
3495 msgid ""
3496 "struct timeval {\n"
3497 "    long    tv_sec;         /* seconds */\n"
3498 "    long    tv_usec;        /* microseconds */\n"
3499 "};\n"
3500 msgstr ""
3501
3502 #. type: Plain text
3503 #: build/C/man2/select.2:247
3504 msgid "and"
3505 msgstr ""
3506
3507 #. type: Plain text
3508 #: build/C/man2/select.2:254
3509 #, no-wrap
3510 msgid ""
3511 "struct timespec {\n"
3512 "    long    tv_sec;         /* seconds */\n"
3513 "    long    tv_nsec;        /* nanoseconds */\n"
3514 "};\n"
3515 msgstr ""
3516
3517 #. type: Plain text
3518 #: build/C/man2/select.2:258
3519 msgid "(However, see below on the POSIX.1-2001 versions.)"
3520 msgstr ""
3521
3522 #. type: Plain text
3523 #: build/C/man2/select.2:266
3524 msgid ""
3525 "Some code calls B<select>()  with all three sets empty, I<nfds> zero, and a "
3526 "non-NULL I<timeout> as a fairly portable way to sleep with subsecond "
3527 "precision."
3528 msgstr ""
3529
3530 #.  .PP - it is rumored that:
3531 #.  On BSD, when a timeout occurs, the file descriptor bits are not changed.
3532 #.  - it is certainly true that:
3533 #.  Linux follows SUSv2 and sets the bit masks to zero upon a timeout.
3534 #. type: Plain text
3535 #: build/C/man2/select.2:289
3536 msgid ""
3537 "On Linux, B<select>()  modifies I<timeout> to reflect the amount of time not "
3538 "slept; most other implementations do not do this.  (POSIX.1-2001 permits "
3539 "either behavior.)  This causes problems both when Linux code which reads "
3540 "I<timeout> is ported to other operating systems, and when code is ported to "
3541 "Linux that reuses a I<struct timeval> for multiple B<select>()s in a loop "
3542 "without reinitializing it.  Consider I<timeout> to be undefined after "
3543 "B<select>()  returns."
3544 msgstr ""
3545
3546 #. type: Plain text
3547 #: build/C/man2/select.2:306
3548 msgid ""
3549 "On success, B<select>()  and B<pselect>()  return the number of file "
3550 "descriptors contained in the three returned descriptor sets (that is, the "
3551 "total number of bits that are set in I<readfds>, I<writefds>, I<exceptfds>)  "
3552 "which may be zero if the timeout expires before anything interesting "
3553 "happens.  On error, -1 is returned, and I<errno> is set appropriately; the "
3554 "sets and I<timeout> become undefined, so do not rely on their contents after "
3555 "an error."
3556 msgstr ""
3557
3558 #. type: Plain text
3559 #: build/C/man2/select.2:312
3560 msgid ""
3561 "An invalid file descriptor was given in one of the sets.  (Perhaps a file "
3562 "descriptor that was already closed, or one on which an error has occurred.)"
3563 msgstr ""
3564
3565 #. type: Plain text
3566 #: build/C/man2/select.2:316
3567 msgid "A signal was caught; see B<signal>(7)."
3568 msgstr ""
3569
3570 #. type: Plain text
3571 #: build/C/man2/select.2:322
3572 msgid "I<nfds> is negative or the value contained within I<timeout> is invalid."
3573 msgstr ""
3574
3575 #. type: Plain text
3576 #: build/C/man2/select.2:325
3577 msgid "unable to allocate memory for internal tables."
3578 msgstr ""
3579
3580 #. type: Plain text
3581 #: build/C/man2/select.2:331
3582 msgid ""
3583 "B<pselect>()  was added to Linux in kernel 2.6.16.  Prior to this, "
3584 "B<pselect>()  was emulated in glibc (but see BUGS)."
3585 msgstr ""
3586
3587 #. type: Plain text
3588 #: build/C/man2/select.2:342
3589 msgid ""
3590 "B<select>()  conforms to POSIX.1-2001 and 4.4BSD (B<select>()  first "
3591 "appeared in 4.2BSD).  Generally portable to/from non-BSD systems supporting "
3592 "clones of the BSD socket layer (including System V variants).  However, note "
3593 "that the System V variant typically sets the timeout variable before exit, "
3594 "but the BSD variant does not."
3595 msgstr ""
3596
3597 #. type: Plain text
3598 #: build/C/man2/select.2:346
3599 msgid "B<pselect>()  is defined in POSIX.1g, and in POSIX.1-2001."
3600 msgstr ""
3601
3602 #. type: Plain text
3603 #: build/C/man2/select.2:363
3604 msgid ""
3605 "An I<fd_set> is a fixed size buffer.  Executing B<FD_CLR>()  or B<FD_SET>()  "
3606 "with a value of I<fd> that is negative or is equal to or larger than "
3607 "B<FD_SETSIZE> will result in undefined behavior.  Moreover, POSIX requires "
3608 "I<fd> to be a valid file descriptor."
3609 msgstr ""
3610
3611 #. type: Plain text
3612 #: build/C/man2/select.2:372
3613 msgid ""
3614 "Concerning the types involved, the classical situation is that the two "
3615 "fields of a I<timeval> structure are typed as I<long> (as shown above), and "
3616 "the structure is defined in I<E<lt>sys/time.hE<gt>>.  The POSIX.1-2001 "
3617 "situation is"
3618 msgstr ""
3619
3620 #. type: Plain text
3621 #: build/C/man2/select.2:379
3622 #, no-wrap
3623 msgid ""
3624 "struct timeval {\n"
3625 "    time_t         tv_sec;     /* seconds */\n"
3626 "    suseconds_t    tv_usec;    /* microseconds */\n"
3627 "};\n"
3628 msgstr ""
3629
3630 #. type: Plain text
3631 #: build/C/man2/select.2:390
3632 msgid ""
3633 "where the structure is defined in I<E<lt>sys/select.hE<gt>> and the data "
3634 "types I<time_t> and I<suseconds_t> are defined in I<E<lt>sys/types.hE<gt>>."
3635 msgstr ""
3636
3637 #. type: Plain text
3638 #: build/C/man2/select.2:402
3639 msgid ""
3640 "Concerning prototypes, the classical situation is that one should include "
3641 "I<E<lt>time.hE<gt>> for B<select>().  The POSIX.1-2001 situation is that one "
3642 "should include I<E<lt>sys/select.hE<gt>> for B<select>()  and B<pselect>()."
3643 msgstr ""
3644
3645 #. type: Plain text
3646 #: build/C/man2/select.2:414
3647 msgid ""
3648 "Libc4 and libc5 do not have a I<E<lt>sys/select.hE<gt>> header; under glibc "
3649 "2.0 and later this header exists.  Under glibc 2.0 it unconditionally gives "
3650 "the wrong prototype for B<pselect>().  Under glibc 2.1 to 2.2.1 it gives "
3651 "B<pselect>()  when B<_GNU_SOURCE> is defined.  Since glibc 2.2.2 the "
3652 "requirements are as shown in the SYNOPSIS."
3653 msgstr ""
3654
3655 #. type: SS
3656 #: build/C/man2/select.2:414
3657 #, no-wrap
3658 msgid "Multithreaded applications"
3659 msgstr ""
3660
3661 #. type: Plain text
3662 #: build/C/man2/select.2:430
3663 msgid ""
3664 "If a file descriptor being monitored by B<select>()  is closed in another "
3665 "thread, the result is unspecified.  On some UNIX systems, B<select>()  "
3666 "unblocks and returns, with an indication that the file descriptor is ready "
3667 "(a subsequent I/O operation will likely fail with an error, unless another "
3668 "the file descriptor reopened between the time B<select>()  returned and the "
3669 "I/O operations was performed).  On Linux (and some other systems), closing "
3670 "the file descriptor in another thread has no effect on B<select>().  In "
3671 "summary, any application that relies on a particular behavior in this "
3672 "scenario must be considered buggy."
3673 msgstr ""
3674
3675 #. type: SS
3676 #: build/C/man2/select.2:430
3677 #, no-wrap
3678 msgid "Linux notes"
3679 msgstr ""
3680
3681 #. type: Plain text
3682 #: build/C/man2/select.2:438
3683 msgid ""
3684 "The B<pselect>()  interface described in this page is implemented by glibc.  "
3685 "The underlying Linux system call is named B<pselect6>().  This system call "
3686 "has somewhat different behavior from the glibc wrapper function."
3687 msgstr ""
3688
3689 #. type: Plain text
3690 #: build/C/man2/select.2:453
3691 msgid ""
3692 "The Linux B<pselect6>()  system call modifies its I<timeout> argument.  "
3693 "However, the glibc wrapper function hides this behavior by using a local "
3694 "variable for the timeout argument that is passed to the system call.  Thus, "
3695 "the glibc B<pselect>()  function does not modify its I<timeout> argument; "
3696 "this is the behavior required by POSIX.1-2001."
3697 msgstr ""
3698
3699 #. type: Plain text
3700 #: build/C/man2/select.2:459
3701 msgid ""
3702 "The final argument of the B<pselect6>()  system call is not a I<sigset_t\\ "
3703 "*> pointer, but is instead a structure of the form:"
3704 msgstr ""
3705
3706 #. type: Plain text
3707 #: build/C/man2/select.2:467
3708 #, no-wrap
3709 msgid ""
3710 "struct {\n"
3711 "    const sigset_t *ss;     /* Pointer to signal set */\n"
3712 "    size_t          ss_len; /* Size (in bytes) of object pointed\n"
3713 "                               to by 'ss' */\n"
3714 "};\n"
3715 msgstr ""
3716
3717 #. type: Plain text
3718 #: build/C/man2/select.2:474
3719 msgid ""
3720 "This allows the system call to obtain both a pointer to the signal set and "
3721 "its size, while allowing for the fact that most architectures support a "
3722 "maximum of 6 arguments to a system call."
3723 msgstr ""
3724
3725 #. type: Plain text
3726 #: build/C/man2/select.2:480
3727 msgid ""
3728 "Glibc 2.0 provided a version of B<pselect>()  that did not take a I<sigmask> "
3729 "argument."
3730 msgstr ""
3731
3732 #. type: Plain text
3733 #: build/C/man2/select.2:493
3734 msgid ""
3735 "Starting with version 2.1, glibc provided an emulation of B<pselect>()  that "
3736 "was implemented using B<sigprocmask>(2)  and B<select>().  This "
3737 "implementation remained vulnerable to the very race condition that "
3738 "B<pselect>()  was designed to prevent.  Modern versions of glibc use the "
3739 "(race-free)  B<pselect>()  system call on kernels where it is provided."
3740 msgstr ""
3741
3742 #. type: Plain text
3743 #: build/C/man2/select.2:506
3744 msgid ""
3745 "On systems that lack B<pselect>(), reliable (and more portable) signal "
3746 "trapping can be achieved using the self-pipe trick.  In this technique, a "
3747 "signal handler writes a byte to a pipe whose other end is monitored by "
3748 "B<select>()  in the main program.  (To avoid possibly blocking when writing "
3749 "to a pipe that may be full or reading from a pipe that may be empty, "
3750 "nonblocking I/O is used when reading from and writing to the pipe.)"
3751 msgstr ""
3752
3753 #.  Stevens discusses a case where accept can block after select
3754 #.  returns successfully because of an intervening RST from the client.
3755 #.  Maybe the kernel should have returned EIO in such a situation?
3756 #. type: Plain text
3757 #: build/C/man2/select.2:522
3758 msgid ""
3759 "Under Linux, B<select>()  may report a socket file descriptor as \"ready for "
3760 "reading\", while nevertheless a subsequent read blocks.  This could for "
3761 "example happen when data has arrived but upon examination has wrong checksum "
3762 "and is discarded.  There may be other circumstances in which a file "
3763 "descriptor is spuriously reported as ready.  Thus it may be safer to use "
3764 "B<O_NONBLOCK> on sockets that should not block."
3765 msgstr ""
3766
3767 #. type: Plain text
3768 #: build/C/man2/select.2:537
3769 msgid ""
3770 "On Linux, B<select>()  also modifies I<timeout> if the call is interrupted "
3771 "by a signal handler (i.e., the B<EINTR> error return).  This is not "
3772 "permitted by POSIX.1-2001.  The Linux B<pselect>()  system call has the same "
3773 "behavior, but the glibc wrapper hides this behavior by internally copying "
3774 "the I<timeout> to a local variable and passing that variable to the system "
3775 "call."
3776 msgstr ""
3777
3778 #. type: Plain text
3779 #: build/C/man2/select.2:544
3780 #, no-wrap
3781 msgid ""
3782 "#include E<lt>stdio.hE<gt>\n"
3783 "#include E<lt>stdlib.hE<gt>\n"
3784 "#include E<lt>sys/time.hE<gt>\n"
3785 "#include E<lt>sys/types.hE<gt>\n"
3786 "#include E<lt>unistd.hE<gt>\n"
3787 msgstr ""
3788
3789 #. type: Plain text
3790 #: build/C/man2/select.2:551
3791 #, no-wrap
3792 msgid ""
3793 "int\n"
3794 "main(void)\n"
3795 "{\n"
3796 "    fd_set rfds;\n"
3797 "    struct timeval tv;\n"
3798 "    int retval;\n"
3799 msgstr ""
3800
3801 #. type: Plain text
3802 #: build/C/man2/select.2:555
3803 #, no-wrap
3804 msgid ""
3805 "    /* Watch stdin (fd 0) to see when it has input. */\n"
3806 "    FD_ZERO(&rfds);\n"
3807 "    FD_SET(0, &rfds);\n"
3808 msgstr ""
3809
3810 #. type: Plain text
3811 #: build/C/man2/select.2:559
3812 #, no-wrap
3813 msgid ""
3814 "    /* Wait up to five seconds. */\n"
3815 "    tv.tv_sec = 5;\n"
3816 "    tv.tv_usec = 0;\n"
3817 msgstr ""
3818
3819 #. type: Plain text
3820 #: build/C/man2/select.2:562
3821 #, no-wrap
3822 msgid ""
3823 "    retval = select(1, &rfds, NULL, NULL, &tv);\n"
3824 "    /* Don't rely on the value of tv now! */\n"
3825 msgstr ""
3826
3827 #. type: Plain text
3828 #: build/C/man2/select.2:570
3829 #, no-wrap
3830 msgid ""
3831 "    if (retval == -1)\n"
3832 "        perror(\"select()\");\n"
3833 "    else if (retval)\n"
3834 "        printf(\"Data is available now.\\en\");\n"
3835 "        /* FD_ISSET(0, &rfds) will be true. */\n"
3836 "    else\n"
3837 "        printf(\"No data within five seconds.\\en\");\n"
3838 msgstr ""
3839
3840 #. type: Plain text
3841 #: build/C/man2/select.2:585
3842 msgid ""
3843 "B<accept>(2), B<connect>(2), B<poll>(2), B<read>(2), B<recv>(2), B<send>(2), "
3844 "B<sigprocmask>(2), B<write>(2), B<epoll>(7), B<time>(7)"
3845 msgstr ""
3846
3847 #. type: Plain text
3848 #: build/C/man2/select.2:588
3849 msgid "For a tutorial with discussion and examples, see B<select_tut>(2)."
3850 msgstr ""
3851
3852 #. type: TH
3853 #: build/C/man2/select_tut.2:32
3854 #, no-wrap
3855 msgid "SELECT_TUT"
3856 msgstr ""
3857
3858 #. type: TH
3859 #: build/C/man2/select_tut.2:32
3860 #, no-wrap
3861 msgid "2012-08-03"
3862 msgstr ""
3863
3864 #. type: Plain text
3865 #: build/C/man2/select_tut.2:52
3866 #, no-wrap
3867 msgid ""
3868 "B<int select(int >I<nfds>B<, fd_set *>I<readfds>B<, fd_set "
3869 "*>I<writefds>B<,>\n"
3870 "B<           fd_set *>I<exceptfds>B<, struct timeval *>I<utimeout>B<);>\n"
3871 msgstr ""
3872
3873 #. type: Plain text
3874 #: build/C/man2/select_tut.2:66
3875 #, no-wrap
3876 msgid ""
3877 "B<int pselect(int >I<nfds>B<, fd_set *>I<readfds>B<, fd_set "
3878 "*>I<writefds>B<,>\n"
3879 "B<            fd_set *>I<exceptfds>B<, const struct timespec "
3880 "*>I<ntimeout>B<,>\n"
3881 "B<            const sigset_t *>I<sigmask>B<);>\n"
3882 msgstr ""
3883
3884 #. type: Plain text
3885 #: build/C/man2/select_tut.2:83
3886 msgid ""
3887 "B<select>()  (or B<pselect>())  is used to efficiently monitor multiple file "
3888 "descriptors, to see if any of them is, or becomes, \"ready\"; that is, to "
3889 "see whether I/O becomes possible, or an \"exceptional condition\" has "
3890 "occurred on any of the descriptors."
3891 msgstr ""
3892
3893 #. type: Plain text
3894 #: build/C/man2/select_tut.2:108
3895 msgid ""
3896 "Its principal arguments are three \"sets\" of file descriptors: I<readfds>, "
3897 "I<writefds>, and I<exceptfds>.  Each set is declared as type I<fd_set>, and "
3898 "its contents can be manipulated with the macros B<FD_CLR>(), B<FD_ISSET>(), "
3899 "B<FD_SET>(), and B<FD_ZERO>().  A newly declared set should first be cleared "
3900 "using B<FD_ZERO>().  B<select>()  modifies the contents of the sets "
3901 "according to the rules described below; after calling B<select>()  you can "
3902 "test if a file descriptor is still present in a set with the B<FD_ISSET>()  "
3903 "macro.  B<FD_ISSET>()  returns nonzero if a specified file descriptor is "
3904 "present in a set and zero if it is not.  B<FD_CLR>()  removes a file "
3905 "descriptor from a set."
3906 msgstr ""
3907
3908 #. type: SS
3909 #: build/C/man2/select_tut.2:108
3910 #, no-wrap
3911 msgid "Arguments"
3912 msgstr ""
3913
3914 #. type: TP
3915 #: build/C/man2/select_tut.2:109
3916 #, no-wrap
3917 msgid "I<readfds>"
3918 msgstr ""
3919
3920 #. type: Plain text
3921 #: build/C/man2/select_tut.2:118
3922 msgid ""
3923 "This set is watched to see if data is available for reading from any of its "
3924 "file descriptors.  After B<select>()  has returned, I<readfds> will be "
3925 "cleared of all file descriptors except for those that are immediately "
3926 "available for reading."
3927 msgstr ""
3928
3929 #. type: TP
3930 #: build/C/man2/select_tut.2:118
3931 #, no-wrap
3932 msgid "I<writefds>"
3933 msgstr ""
3934
3935 #. type: Plain text
3936 #: build/C/man2/select_tut.2:127
3937 msgid ""
3938 "This set is watched to see if there is space to write data to any of its "
3939 "file descriptors.  After B<select>()  has returned, I<writefds> will be "
3940 "cleared of all file descriptors except for those that are immediately "
3941 "available for writing."
3942 msgstr ""
3943
3944 #. type: TP
3945 #: build/C/man2/select_tut.2:127
3946 #, no-wrap
3947 msgid "I<exceptfds>"
3948 msgstr ""
3949
3950 #. type: Plain text
3951 #: build/C/man2/select_tut.2:149
3952 msgid ""
3953 "This set is watched for \"exceptional conditions\".  In practice, only one "
3954 "such exceptional condition is common: the availability of I<out-of-band> "
3955 "(OOB) data for reading from a TCP socket.  See B<recv>(2), B<send>(2), and "
3956 "B<tcp>(7)  for more details about OOB data.  (One other less common case "
3957 "where B<select>(2)  indicates an exceptional condition occurs with "
3958 "pseudoterminals in packet mode; see B<tty_ioctl>(4).)  After B<select>()  "
3959 "has returned, I<exceptfds> will be cleared of all file descriptors except "
3960 "for those for which an exceptional condition has occurred."
3961 msgstr ""
3962
3963 #. type: TP
3964 #: build/C/man2/select_tut.2:149
3965 #, no-wrap
3966 msgid "I<nfds>"
3967 msgstr ""
3968
3969 #. type: Plain text
3970 #: build/C/man2/select_tut.2:156
3971 msgid ""
3972 "This is an integer one more than the maximum of any file descriptor in any "
3973 "of the sets.  In other words, while adding file descriptors to each of the "
3974 "sets, you must calculate the maximum integer value of all of them, then "
3975 "increment this value by one, and then pass this as I<nfds>."
3976 msgstr ""
3977
3978 #. type: TP
3979 #: build/C/man2/select_tut.2:156
3980 #, no-wrap
3981 msgid "I<utimeout>"
3982 msgstr ""
3983
3984 #. type: Plain text
3985 #: build/C/man2/select_tut.2:169
3986 msgid ""
3987 "This is the longest time B<select>()  may wait before returning, even if "
3988 "nothing interesting happened.  If this value is passed as NULL, then "
3989 "B<select>()  blocks indefinitely waiting for a file descriptor to become "
3990 "ready.  I<utimeout> can be set to zero seconds, which causes B<select>()  to "
3991 "return immediately, with information about the readiness of file descriptors "
3992 "at the time of the call.  The structure I<struct timeval> is defined as:"
3993 msgstr ""
3994
3995 #. type: Plain text
3996 #: build/C/man2/select_tut.2:176
3997 #, no-wrap
3998 msgid ""
3999 "struct timeval {\n"
4000 "    time_t tv_sec;    /* seconds */\n"
4001 "    long tv_usec;     /* microseconds */\n"
4002 "};\n"
4003 msgstr ""
4004
4005 #. type: TP
4006 #: build/C/man2/select_tut.2:178
4007 #, no-wrap
4008 msgid "I<ntimeout>"
4009 msgstr ""
4010
4011 #. type: Plain text
4012 #: build/C/man2/select_tut.2:187
4013 msgid ""
4014 "This argument for B<pselect>()  has the same meaning as I<utimeout>, but "
4015 "I<struct timespec> has nanosecond precision as follows:"
4016 msgstr ""
4017
4018 #. type: Plain text
4019 #: build/C/man2/select_tut.2:194
4020 #, no-wrap
4021 msgid ""
4022 "struct timespec {\n"
4023 "    long tv_sec;    /* seconds */\n"
4024 "    long tv_nsec;   /* nanoseconds */\n"
4025 "};\n"
4026 msgstr ""
4027
4028 #. type: TP
4029 #: build/C/man2/select_tut.2:196
4030 #, no-wrap
4031 msgid "I<sigmask>"
4032 msgstr ""
4033
4034 #. type: Plain text
4035 #: build/C/man2/select_tut.2:213
4036 msgid ""
4037 "This argument holds a set of signals that the kernel should unblock (i.e., "
4038 "remove from the signal mask of the calling thread), while the caller is "
4039 "blocked inside the B<pselect>()  call (see B<sigaddset>(3)  and "
4040 "B<sigprocmask>(2)).  It may be NULL, in which case the call does not modify "
4041 "the signal mask on entry and exit to the function.  In this case, "
4042 "B<pselect>()  will then behave just like B<select>()."
4043 msgstr ""
4044
4045 #. type: SS
4046 #: build/C/man2/select_tut.2:213
4047 #, no-wrap
4048 msgid "Combining signal and data events"
4049 msgstr ""
4050
4051 #. type: Plain text
4052 #: build/C/man2/select_tut.2:257
4053 msgid ""
4054 "B<pselect>()  is useful if you are waiting for a signal as well as for file "
4055 "descriptor(s) to become ready for I/O.  Programs that receive signals "
4056 "normally use the signal handler only to raise a global flag.  The global "
4057 "flag will indicate that the event must be processed in the main loop of the "
4058 "program.  A signal will cause the B<select>()  (or B<pselect>())  call to "
4059 "return with I<errno> set to B<EINTR>.  This behavior is essential so that "
4060 "signals can be processed in the main loop of the program, otherwise "
4061 "B<select>()  would block indefinitely.  Now, somewhere in the main loop will "
4062 "be a conditional to check the global flag.  So we must ask: what if a signal "
4063 "arrives after the conditional, but before the B<select>()  call? The answer "
4064 "is that B<select>()  would block indefinitely, even though an event is "
4065 "actually pending.  This race condition is solved by the B<pselect>()  call.  "
4066 "This call can be used to set the signal mask to a set of signals that are "
4067 "only to be received within the B<pselect>()  call.  For instance, let us say "
4068 "that the event in question was the exit of a child process.  Before the "
4069 "start of the main loop, we would block B<SIGCHLD> using B<sigprocmask>(2).  "
4070 "Our B<pselect>()  call would enable B<SIGCHLD> by using an empty signal "
4071 "mask.  Our program would look like:"
4072 msgstr ""
4073
4074 #. type: Plain text
4075 #: build/C/man2/select_tut.2:260
4076 #, no-wrap
4077 msgid "static volatile sig_atomic_t got_SIGCHLD = 0;\n"
4078 msgstr ""
4079
4080 #. type: Plain text
4081 #: build/C/man2/select_tut.2:266
4082 #, no-wrap
4083 msgid ""
4084 "static void\n"
4085 "child_sig_handler(int sig)\n"
4086 "{\n"
4087 "    got_SIGCHLD = 1;\n"
4088 "}\n"
4089 msgstr ""
4090
4091 #. type: Plain text
4092 #: build/C/man2/select_tut.2:274
4093 #, no-wrap
4094 msgid ""
4095 "int\n"
4096 "main(int argc, char *argv[])\n"
4097 "{\n"
4098 "    sigset_t sigmask, empty_mask;\n"
4099 "    struct sigaction sa;\n"
4100 "    fd_set readfds, writefds, exceptfds;\n"
4101 "    int r;\n"
4102 msgstr ""
4103
4104 #. type: Plain text
4105 #: build/C/man2/select_tut.2:281
4106 #, no-wrap
4107 msgid ""
4108 "    sigemptyset(&sigmask);\n"
4109 "    sigaddset(&sigmask, SIGCHLD);\n"
4110 "    if (sigprocmask(SIG_BLOCK, &sigmask, NULL) == -1) {\n"
4111 "        perror(\"sigprocmask\");\n"
4112 "        exit(EXIT_FAILURE);\n"
4113 "    }\n"
4114 msgstr ""
4115
4116 #. type: Plain text
4117 #: build/C/man2/select_tut.2:289
4118 #, no-wrap
4119 msgid ""
4120 "    sa.sa_flags = 0;\n"
4121 "    sa.sa_handler = child_sig_handler;\n"
4122 "    sigemptyset(&sa.sa_mask);\n"
4123 "    if (sigaction(SIGCHLD, &sa, NULL) == -1) {\n"
4124 "        perror(\"sigaction\");\n"
4125 "        exit(EXIT_FAILURE);\n"
4126 "    }\n"
4127 msgstr ""
4128
4129 #. type: Plain text
4130 #: build/C/man2/select_tut.2:291
4131 #, no-wrap
4132 msgid "    sigemptyset(&empty_mask);\n"
4133 msgstr ""
4134
4135 #. type: Plain text
4136 #: build/C/man2/select_tut.2:295
4137 #, no-wrap
4138 msgid ""
4139 "    for (;;) {          /* main loop */\n"
4140 "        /* Initialize readfds, writefds, and exceptfds\n"
4141 "           before the pselect() call. (Code omitted.) */\n"
4142 msgstr ""
4143
4144 #. type: Plain text
4145 #: build/C/man2/select_tut.2:301
4146 #, no-wrap
4147 msgid ""
4148 "        r = pselect(nfds, &readfds, &writefds, &exceptfds,\n"
4149 "                    NULL, &empty_mask);\n"
4150 "        if (r == -1 && errno != EINTR) {\n"
4151 "            /* Handle error */\n"
4152 "        }\n"
4153 msgstr ""
4154
4155 #. type: Plain text
4156 #: build/C/man2/select_tut.2:304
4157 #, no-wrap
4158 msgid ""
4159 "        if (got_SIGCHLD) {\n"
4160 "            got_SIGCHLD = 0;\n"
4161 msgstr ""
4162
4163 #. type: Plain text
4164 #: build/C/man2/select_tut.2:308
4165 #, no-wrap
4166 msgid ""
4167 "            /* Handle signalled event here; e.g., wait() for all\n"
4168 "               terminated children. (Code omitted.) */\n"
4169 "        }\n"
4170 msgstr ""
4171
4172 #. type: Plain text
4173 #: build/C/man2/select_tut.2:312
4174 #, no-wrap
4175 msgid ""
4176 "        /* main body of program */\n"
4177 "    }\n"
4178 "}\n"
4179 msgstr ""
4180
4181 #. type: SS
4182 #: build/C/man2/select_tut.2:313
4183 #, no-wrap
4184 msgid "Practical"
4185 msgstr ""
4186
4187 #. type: Plain text
4188 #: build/C/man2/select_tut.2:334
4189 msgid ""
4190 "So what is the point of B<select>()? Can't I just read and write to my "
4191 "descriptors whenever I want? The point of B<select>()  is that it watches "
4192 "multiple descriptors at the same time and properly puts the process to sleep "
4193 "if there is no activity.  UNIX programmers often find themselves in a "
4194 "position where they have to handle I/O from more than one file descriptor "
4195 "where the data flow may be intermittent.  If you were to merely create a "
4196 "sequence of B<read>(2)  and B<write>(2)  calls, you would find that one of "
4197 "your calls may block waiting for data from/to a file descriptor, while "
4198 "another file descriptor is unused though ready for I/O.  B<select>()  "
4199 "efficiently copes with this situation."
4200 msgstr ""
4201
4202 #. type: SS
4203 #: build/C/man2/select_tut.2:334
4204 #, no-wrap
4205 msgid "Select law"
4206 msgstr ""
4207
4208 #. type: Plain text
4209 #: build/C/man2/select_tut.2:347
4210 msgid ""
4211 "Many people who try to use B<select>()  come across behavior that is "
4212 "difficult to understand and produces nonportable or borderline results.  For "
4213 "instance, the above program is carefully written not to block at any point, "
4214 "even though it does not set its file descriptors to nonblocking mode.  It is "
4215 "easy to introduce subtle errors that will remove the advantage of using "
4216 "B<select>(), so here is a list of essentials to watch for when using "
4217 "B<select>()."
4218 msgstr ""
4219
4220 #. type: Plain text
4221 #: build/C/man2/select_tut.2:356
4222 msgid ""
4223 "You should always try to use B<select>()  without a timeout.  Your program "
4224 "should have nothing to do if there is no data available.  Code that depends "
4225 "on timeouts is not usually portable and is difficult to debug."
4226 msgstr ""
4227
4228 #. type: Plain text
4229 #: build/C/man2/select_tut.2:360
4230 msgid ""
4231 "The value I<nfds> must be properly calculated for efficiency as explained "
4232 "above."
4233 msgstr ""
4234
4235 #. type: Plain text
4236 #: build/C/man2/select_tut.2:367
4237 msgid ""
4238 "No file descriptor must be added to any set if you do not intend to check "
4239 "its result after the B<select>()  call, and respond appropriately.  See next "
4240 "rule."
4241 msgstr ""
4242
4243 #. type: Plain text
4244 #: build/C/man2/select_tut.2:373
4245 msgid ""
4246 "After B<select>()  returns, all file descriptors in all sets should be "
4247 "checked to see if they are ready."
4248 msgstr ""
4249
4250 #. type: TP
4251 #: build/C/man2/select_tut.2:373
4252 #, no-wrap
4253 msgid "5."
4254 msgstr ""
4255
4256 #. type: Plain text
4257 #: build/C/man2/select_tut.2:388
4258 msgid ""
4259 "The functions B<read>(2), B<recv>(2), B<write>(2), and B<send>(2)  do I<not> "
4260 "necessarily read/write the full amount of data that you have requested.  If "
4261 "they do read/write the full amount, it's because you have a low traffic load "
4262 "and a fast stream.  This is not always going to be the case.  You should "
4263 "cope with the case of your functions only managing to send or receive a "
4264 "single byte."
4265 msgstr ""
4266
4267 #. type: TP
4268 #: build/C/man2/select_tut.2:388
4269 #, no-wrap
4270 msgid "6."
4271 msgstr ""
4272
4273 #. type: Plain text
4274 #: build/C/man2/select_tut.2:396
4275 msgid ""
4276 "Never read/write only in single bytes at a time unless you are really sure "
4277 "that you have a small amount of data to process.  It is extremely "
4278 "inefficient not to read/write as much data as you can buffer each time.  The "
4279 "buffers in the example below are 1024 bytes although they could easily be "
4280 "made larger."
4281 msgstr ""
4282
4283 #. type: TP
4284 #: build/C/man2/select_tut.2:396
4285 #, no-wrap
4286 msgid "7."
4287 msgstr ""
4288
4289 #.  Nonetheless, you should still cope with these errors for completeness.
4290 #. type: Plain text
4291 #: build/C/man2/select_tut.2:418
4292 msgid ""
4293 "The functions B<read>(2), B<recv>(2), B<write>(2), and B<send>(2)  as well "
4294 "as the B<select>()  call can return -1 with I<errno> set to B<EINTR>, or "
4295 "with I<errno> set to B<EAGAIN> (B<EWOULDBLOCK>).  These results must be "
4296 "properly managed (not done properly above).  If your program is not going to "
4297 "receive any signals, then it is unlikely you will get B<EINTR>.  If your "
4298 "program does not set nonblocking I/O, you will not get B<EAGAIN>."
4299 msgstr ""
4300
4301 #. type: TP
4302 #: build/C/man2/select_tut.2:418
4303 #, no-wrap
4304 msgid "8."
4305 msgstr ""
4306
4307 #. type: Plain text
4308 #: build/C/man2/select_tut.2:427
4309 msgid ""
4310 "Never call B<read>(2), B<recv>(2), B<write>(2), or B<send>(2)  with a buffer "
4311 "length of zero."
4312 msgstr ""
4313
4314 #. type: TP
4315 #: build/C/man2/select_tut.2:427
4316 #, no-wrap
4317 msgid "9."
4318 msgstr ""
4319
4320 #. type: Plain text
4321 #: build/C/man2/select_tut.2:443
4322 msgid ""
4323 "If the functions B<read>(2), B<recv>(2), B<write>(2), and B<send>(2)  fail "
4324 "with errors other than those listed in B<7.>, or one of the input functions "
4325 "returns 0, indicating end of file, then you should I<not> pass that "
4326 "descriptor to B<select>()  again.  In the example below, I close the "
4327 "descriptor immediately, and then set it to -1 to prevent it being included "
4328 "in a set."
4329 msgstr ""
4330
4331 #. type: TP
4332 #: build/C/man2/select_tut.2:443
4333 #, no-wrap
4334 msgid "10."
4335 msgstr ""
4336
4337 #. type: Plain text
4338 #: build/C/man2/select_tut.2:450
4339 msgid ""
4340 "The timeout value must be initialized with each new call to B<select>(), "
4341 "since some operating systems modify the structure.  B<pselect>()  however "
4342 "does not modify its timeout structure."
4343 msgstr ""
4344
4345 #. type: TP
4346 #: build/C/man2/select_tut.2:450
4347 #, no-wrap
4348 msgid "11."
4349 msgstr ""
4350
4351 #.  "I have heard" does not fill me with confidence, and doesn't
4352 #.  belong in a man page, so I've commented this point out.
4353 #.  .TP
4354 #.  11.
4355 #.  I have heard that the Windows socket layer does not cope with OOB data
4356 #.  properly.
4357 #.  It also does not cope with
4358 #.  .BR select ()
4359 #.  calls when no file descriptors are set at all.
4360 #.  Having no file descriptors set is a useful
4361 #.  way to sleep the process with subsecond precision by using the timeout.
4362 #.  (See further on.)
4363 #. type: Plain text
4364 #: build/C/man2/select_tut.2:469
4365 msgid ""
4366 "Since B<select>()  modifies its file descriptor sets, if the call is being "
4367 "used in a loop, then the sets must be reinitialized before each call."
4368 msgstr ""
4369
4370 #. type: SS
4371 #: build/C/man2/select_tut.2:469
4372 #, no-wrap
4373 msgid "Usleep emulation"
4374 msgstr ""
4375
4376 #. type: Plain text
4377 #: build/C/man2/select_tut.2:476
4378 msgid ""
4379 "On systems that do not have a B<usleep>(3)  function, you can call "
4380 "B<select>()  with a finite timeout and no file descriptors as follows:"
4381 msgstr ""
4382
4383 #. type: Plain text
4384 #: build/C/man2/select_tut.2:482
4385 #, no-wrap
4386 msgid ""
4387 "    struct timeval tv;\n"
4388 "    tv.tv_sec = 0;\n"
4389 "    tv.tv_usec = 200000;  /* 0.2 seconds */\n"
4390 "    select(0, NULL, NULL, NULL, &tv);\n"
4391 msgstr ""
4392
4393 #. type: Plain text
4394 #: build/C/man2/select_tut.2:485
4395 msgid "This is only guaranteed to work on UNIX systems, however."
4396 msgstr ""
4397
4398 #. type: Plain text
4399 #: build/C/man2/select_tut.2:490
4400 msgid ""
4401 "On success, B<select>()  returns the total number of file descriptors still "
4402 "present in the file descriptor sets."
4403 msgstr ""
4404
4405 #. type: Plain text
4406 #: build/C/man2/select_tut.2:496
4407 msgid ""
4408 "If B<select>()  timed out, then the return value will be zero.  The file "
4409 "descriptors set should be all empty (but may not be on some systems)."
4410 msgstr ""
4411
4412 #. type: Plain text
4413 #: build/C/man2/select_tut.2:503
4414 msgid ""
4415 "A return value of -1 indicates an error, with I<errno> being set "
4416 "appropriately.  In the case of an error, the contents of the returned sets "
4417 "and the I<struct timeout> contents are undefined and should not be used.  "
4418 "B<pselect>()  however never modifies I<ntimeout>."
4419 msgstr ""
4420
4421 #. type: Plain text
4422 #: build/C/man2/select_tut.2:512
4423 msgid ""
4424 "Generally speaking, all operating systems that support sockets also support "
4425 "B<select>().  B<select>()  can be used to solve many problems in a portable "
4426 "and efficient way that naive programmers try to solve in a more complicated "
4427 "manner using threads, forking, IPCs, signals, memory sharing, and so on."
4428 msgstr ""
4429
4430 #. type: Plain text
4431 #: build/C/man2/select_tut.2:521
4432 msgid ""
4433 "The B<poll>(2)  system call has the same functionality as B<select>(), and "
4434 "is somewhat more efficient when monitoring sparse file descriptor sets.  It "
4435 "is nowadays widely available, but historically was less portable than "
4436 "B<select>()."
4437 msgstr ""
4438
4439 #. type: Plain text
4440 #: build/C/man2/select_tut.2:529
4441 msgid ""
4442 "The Linux-specific B<epoll>(7)  API provides an interface that is more "
4443 "efficient than B<select>(2)  and B<poll>(2)  when monitoring large numbers "
4444 "of file descriptors."
4445 msgstr ""
4446
4447 #. type: Plain text
4448 #: build/C/man2/select_tut.2:534
4449 msgid ""
4450 "Here is an example that better demonstrates the true utility of "
4451 "B<select>().  The listing below is a TCP forwarding program that forwards "
4452 "from one TCP port to another."
4453 msgstr ""
4454
4455 #. type: Plain text
4456 #: build/C/man2/select_tut.2:547
4457 #, no-wrap
4458 msgid ""
4459 "#include E<lt>stdlib.hE<gt>\n"
4460 "#include E<lt>stdio.hE<gt>\n"
4461 "#include E<lt>unistd.hE<gt>\n"
4462 "#include E<lt>sys/time.hE<gt>\n"
4463 "#include E<lt>sys/types.hE<gt>\n"
4464 "#include E<lt>string.hE<gt>\n"
4465 "#include E<lt>signal.hE<gt>\n"
4466 "#include E<lt>sys/socket.hE<gt>\n"
4467 "#include E<lt>netinet/in.hE<gt>\n"
4468 "#include E<lt>arpa/inet.hE<gt>\n"
4469 "#include E<lt>errno.hE<gt>\n"
4470 msgstr ""
4471
4472 #. type: Plain text
4473 #: build/C/man2/select_tut.2:549
4474 #, no-wrap
4475 msgid "static int forward_port;\n"
4476 msgstr ""
4477
4478 #. type: Plain text
4479 #: build/C/man2/select_tut.2:552
4480 #, no-wrap
4481 msgid ""
4482 "#undef max\n"
4483 "#define max(x,y) ((x) E<gt> (y) ? (x) : (y))\n"
4484 msgstr ""
4485
4486 #. type: Plain text
4487 #: build/C/man2/select_tut.2:559
4488 #, no-wrap
4489 msgid ""
4490 "static int\n"
4491 "listen_socket(int listen_port)\n"
4492 "{\n"
4493 "    struct sockaddr_in a;\n"
4494 "    int s;\n"
4495 "    int yes;\n"
4496 msgstr ""
4497
4498 #. type: Plain text
4499 #: build/C/man2/select_tut.2:583
4500 #, no-wrap
4501 msgid ""
4502 "    if ((s = socket(AF_INET, SOCK_STREAM, 0)) == -1) {\n"
4503 "        perror(\"socket\");\n"
4504 "        return -1;\n"
4505 "    }\n"
4506 "    yes = 1;\n"
4507 "    if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR,\n"
4508 "            &yes, sizeof(yes)) == -1) {\n"
4509 "        perror(\"setsockopt\");\n"
4510 "        close(s);\n"
4511 "        return -1;\n"
4512 "    }\n"
4513 "    memset(&a, 0, sizeof(a));\n"
4514 "    a.sin_port = htons(listen_port);\n"
4515 "    a.sin_family = AF_INET;\n"
4516 "    if (bind(s, (struct sockaddr *) &a, sizeof(a)) == -1) {\n"
4517 "        perror(\"bind\");\n"
4518 "        close(s);\n"
4519 "        return -1;\n"
4520 "    }\n"
4521 "    printf(\"accepting connections on port %d\\en\", listen_port);\n"
4522 "    listen(s, 10);\n"
4523 "    return s;\n"
4524 "}\n"
4525 msgstr ""
4526
4527 #. type: Plain text
4528 #: build/C/man2/select_tut.2:589
4529 #, no-wrap
4530 msgid ""
4531 "static int\n"
4532 "connect_socket(int connect_port, char *address)\n"
4533 "{\n"
4534 "    struct sockaddr_in a;\n"
4535 "    int s;\n"
4536 msgstr ""
4537
4538 #. type: Plain text
4539 #: build/C/man2/select_tut.2:595
4540 #, no-wrap
4541 msgid ""
4542 "    if ((s = socket(AF_INET, SOCK_STREAM, 0)) == -1) {\n"
4543 "        perror(\"socket\");\n"
4544 "        close(s);\n"
4545 "        return -1;\n"
4546 "    }\n"
4547 msgstr ""
4548
4549 #. type: Plain text
4550 #: build/C/man2/select_tut.2:599
4551 #, no-wrap
4552 msgid ""
4553 "    memset(&a, 0, sizeof(a));\n"
4554 "    a.sin_port = htons(connect_port);\n"
4555 "    a.sin_family = AF_INET;\n"
4556 msgstr ""
4557
4558 #. type: Plain text
4559 #: build/C/man2/select_tut.2:605
4560 #, no-wrap
4561 msgid ""
4562 "    if (!inet_aton(address, (struct in_addr *) &a.sin_addr.s_addr)) {\n"
4563 "        perror(\"bad IP address format\");\n"
4564 "        close(s);\n"
4565 "        return -1;\n"
4566 "    }\n"
4567 msgstr ""
4568
4569 #. type: Plain text
4570 #: build/C/man2/select_tut.2:614
4571 #, no-wrap
4572 msgid ""
4573 "    if (connect(s, (struct sockaddr *) &a, sizeof(a)) == -1) {\n"
4574 "        perror(\"connect()\");\n"
4575 "        shutdown(s, SHUT_RDWR);\n"
4576 "        close(s);\n"
4577 "        return -1;\n"
4578 "    }\n"
4579 "    return s;\n"
4580 "}\n"
4581 msgstr ""
4582
4583 #. type: Plain text
4584 #: build/C/man2/select_tut.2:622
4585 #, no-wrap
4586 msgid ""
4587 "#define SHUT_FD1 do {                                \\e\n"
4588 "                     if (fd1 E<gt>= 0) {                 \\e\n"
4589 "                         shutdown(fd1, SHUT_RDWR);   \\e\n"
4590 "                         close(fd1);                 \\e\n"
4591 "                         fd1 = -1;                   \\e\n"
4592 "                     }                               \\e\n"
4593 "                 } while (0)\n"
4594 msgstr ""
4595
4596 #. type: Plain text
4597 #: build/C/man2/select_tut.2:630
4598 #, no-wrap
4599 msgid ""
4600 "#define SHUT_FD2 do {                                \\e\n"
4601 "                     if (fd2 E<gt>= 0) {                 \\e\n"
4602 "                         shutdown(fd2, SHUT_RDWR);   \\e\n"
4603 "                         close(fd2);                 \\e\n"
4604 "                         fd2 = -1;                   \\e\n"
4605 "                     }                               \\e\n"
4606 "                 } while (0)\n"
4607 msgstr ""
4608
4609 #. type: Plain text
4610 #: build/C/man2/select_tut.2:632
4611 #, no-wrap
4612 msgid "#define BUF_SIZE 1024\n"
4613 msgstr ""
4614
4615 #. type: Plain text
4616 #: build/C/man2/select_tut.2:641
4617 #, no-wrap
4618 msgid ""
4619 "int\n"
4620 "main(int argc, char *argv[])\n"
4621 "{\n"
4622 "    int h;\n"
4623 "    int fd1 = -1, fd2 = -1;\n"
4624 "    char buf1[BUF_SIZE], buf2[BUF_SIZE];\n"
4625 "    int buf1_avail, buf1_written;\n"
4626 "    int buf2_avail, buf2_written;\n"
4627 msgstr ""
4628
4629 #. type: Plain text
4630 #: build/C/man2/select_tut.2:647
4631 #, no-wrap
4632 msgid ""
4633 "    if (argc != 4) {\n"
4634 "        fprintf(stderr, \"Usage\\en\\etfwd E<lt>listen-portE<gt> \"\n"
4635 "                 \"E<lt>forward-to-portE<gt> "
4636 "E<lt>forward-to-ip-addressE<gt>\\en\");\n"
4637 "        exit(EXIT_FAILURE);\n"
4638 "    }\n"
4639 msgstr ""
4640
4641 #. type: Plain text
4642 #: build/C/man2/select_tut.2:649
4643 #, no-wrap
4644 msgid "    signal(SIGPIPE, SIG_IGN);\n"
4645 msgstr ""
4646
4647 #. type: Plain text
4648 #: build/C/man2/select_tut.2:651
4649 #, no-wrap
4650 msgid "    forward_port = atoi(argv[2]);\n"
4651 msgstr ""
4652
4653 #. type: Plain text
4654 #: build/C/man2/select_tut.2:655
4655 #, no-wrap
4656 msgid ""
4657 "    h = listen_socket(atoi(argv[1]));\n"
4658 "    if (h == -1)\n"
4659 "        exit(EXIT_FAILURE);\n"
4660 msgstr ""
4661
4662 #. type: Plain text
4663 #: build/C/man2/select_tut.2:659
4664 #, no-wrap
4665 msgid ""
4666 "    for (;;) {\n"
4667 "        int r, nfds = 0;\n"
4668 "        fd_set rd, wr, er;\n"
4669 msgstr ""
4670
4671 #. type: Plain text
4672 #: build/C/man2/select_tut.2:689
4673 #, no-wrap
4674 msgid ""
4675 "        FD_ZERO(&rd);\n"
4676 "        FD_ZERO(&wr);\n"
4677 "        FD_ZERO(&er);\n"
4678 "        FD_SET(h, &rd);\n"
4679 "        nfds = max(nfds, h);\n"
4680 "        if (fd1 E<gt> 0 && buf1_avail E<lt> BUF_SIZE) {\n"
4681 "            FD_SET(fd1, &rd);\n"
4682 "            nfds = max(nfds, fd1);\n"
4683 "        }\n"
4684 "        if (fd2 E<gt> 0 && buf2_avail E<lt> BUF_SIZE) {\n"
4685 "            FD_SET(fd2, &rd);\n"
4686 "            nfds = max(nfds, fd2);\n"
4687 "        }\n"
4688 "        if (fd1 E<gt> 0 && buf2_avail - buf2_written E<gt> 0) {\n"
4689 "            FD_SET(fd1, &wr);\n"
4690 "            nfds = max(nfds, fd1);\n"
4691 "        }\n"
4692 "        if (fd2 E<gt> 0 && buf1_avail - buf1_written E<gt> 0) {\n"
4693 "            FD_SET(fd2, &wr);\n"
4694 "            nfds = max(nfds, fd2);\n"
4695 "        }\n"
4696 "        if (fd1 E<gt> 0) {\n"
4697 "            FD_SET(fd1, &er);\n"
4698 "            nfds = max(nfds, fd1);\n"
4699 "        }\n"
4700 "        if (fd2 E<gt> 0) {\n"
4701 "            FD_SET(fd2, &er);\n"
4702 "            nfds = max(nfds, fd2);\n"
4703 "        }\n"
4704 msgstr ""
4705
4706 #. type: Plain text
4707 #: build/C/man2/select_tut.2:691
4708 #, no-wrap
4709 msgid "        r = select(nfds + 1, &rd, &wr, &er, NULL);\n"
4710 msgstr ""
4711
4712 #. type: Plain text
4713 #: build/C/man2/select_tut.2:694
4714 #, no-wrap
4715 msgid ""
4716 "        if (r == -1 && errno == EINTR)\n"
4717 "            continue;\n"
4718 msgstr ""
4719
4720 #. type: Plain text
4721 #: build/C/man2/select_tut.2:699
4722 #, no-wrap
4723 msgid ""
4724 "        if (r == -1) {\n"
4725 "            perror(\"select()\");\n"
4726 "            exit(EXIT_FAILURE);\n"
4727 "        }\n"
4728 msgstr ""
4729
4730 #. type: Plain text
4731 #: build/C/man2/select_tut.2:703
4732 #, no-wrap
4733 msgid ""
4734 "        if (FD_ISSET(h, &rd)) {\n"
4735 "            unsigned int l;\n"
4736 "            struct sockaddr_in client_address;\n"
4737 msgstr ""
4738
4739 #. type: Plain text
4740 #: build/C/man2/select_tut.2:722
4741 #, no-wrap
4742 msgid ""
4743 "            memset(&client_address, 0, l = sizeof(client_address));\n"
4744 "            r = accept(h, (struct sockaddr *) &client_address, &l);\n"
4745 "            if (r == -1) {\n"
4746 "                perror(\"accept()\");\n"
4747 "            } else {\n"
4748 "                SHUT_FD1;\n"
4749 "                SHUT_FD2;\n"
4750 "                buf1_avail = buf1_written = 0;\n"
4751 "                buf2_avail = buf2_written = 0;\n"
4752 "                fd1 = r;\n"
4753 "                fd2 = connect_socket(forward_port, argv[3]);\n"
4754 "                if (fd2 == -1)\n"
4755 "                    SHUT_FD1;\n"
4756 "                else\n"
4757 "                    printf(\"connect from %s\\en\",\n"
4758 "                            inet_ntoa(client_address.sin_addr));\n"
4759 "            }\n"
4760 "        }\n"
4761 msgstr ""
4762
4763 #. type: Plain text
4764 #: build/C/man2/select_tut.2:724
4765 #, no-wrap
4766 msgid "        /* NB: read oob data before normal reads */\n"
4767 msgstr ""
4768
4769 #. type: Plain text
4770 #: build/C/man2/select_tut.2:728
4771 #, no-wrap
4772 msgid ""
4773 "        if (fd1 E<gt> 0)\n"
4774 "            if (FD_ISSET(fd1, &er)) {\n"
4775 "                char c;\n"
4776 msgstr ""
4777
4778 #. type: Plain text
4779 #: build/C/man2/select_tut.2:738
4780 #, no-wrap
4781 msgid ""
4782 "                r = recv(fd1, &c, 1, MSG_OOB);\n"
4783 "                if (r E<lt> 1)\n"
4784 "                    SHUT_FD1;\n"
4785 "                else\n"
4786 "                    send(fd2, &c, 1, MSG_OOB);\n"
4787 "            }\n"
4788 "        if (fd2 E<gt> 0)\n"
4789 "            if (FD_ISSET(fd2, &er)) {\n"
4790 "                char c;\n"
4791 msgstr ""
4792
4793 #. type: Plain text
4794 #: build/C/man2/select_tut.2:781
4795 #, no-wrap
4796 msgid ""
4797 "                r = recv(fd2, &c, 1, MSG_OOB);\n"
4798 "                if (r E<lt> 1)\n"
4799 "                    SHUT_FD2;\n"
4800 "                else\n"
4801 "                    send(fd1, &c, 1, MSG_OOB);\n"
4802 "            }\n"
4803 "        if (fd1 E<gt> 0)\n"
4804 "            if (FD_ISSET(fd1, &rd)) {\n"
4805 "                r = read(fd1, buf1 + buf1_avail,\n"
4806 "                          BUF_SIZE - buf1_avail);\n"
4807 "                if (r E<lt> 1)\n"
4808 "                    SHUT_FD1;\n"
4809 "                else\n"
4810 "                    buf1_avail += r;\n"
4811 "            }\n"
4812 "        if (fd2 E<gt> 0)\n"
4813 "            if (FD_ISSET(fd2, &rd)) {\n"
4814 "                r = read(fd2, buf2 + buf2_avail,\n"
4815 "                          BUF_SIZE - buf2_avail);\n"
4816 "                if (r E<lt> 1)\n"
4817 "                    SHUT_FD2;\n"
4818 "                else\n"
4819 "                    buf2_avail += r;\n"
4820 "            }\n"
4821 "        if (fd1 E<gt> 0)\n"
4822 "            if (FD_ISSET(fd1, &wr)) {\n"
4823 "                r = write(fd1, buf2 + buf2_written,\n"
4824 "                           buf2_avail - buf2_written);\n"
4825 "                if (r E<lt> 1)\n"
4826 "                    SHUT_FD1;\n"
4827 "                else\n"
4828 "                    buf2_written += r;\n"
4829 "            }\n"
4830 "        if (fd2 E<gt> 0)\n"
4831 "            if (FD_ISSET(fd2, &wr)) {\n"
4832 "                r = write(fd2, buf1 + buf1_written,\n"
4833 "                           buf1_avail - buf1_written);\n"
4834 "                if (r E<lt> 1)\n"
4835 "                    SHUT_FD2;\n"
4836 "                else\n"
4837 "                    buf1_written += r;\n"
4838 "            }\n"
4839 msgstr ""
4840
4841 #. type: Plain text
4842 #: build/C/man2/select_tut.2:783
4843 #, no-wrap
4844 msgid "        /* check if write data has caught read data */\n"
4845 msgstr ""
4846
4847 #. type: Plain text
4848 #: build/C/man2/select_tut.2:788
4849 #, no-wrap
4850 msgid ""
4851 "        if (buf1_written == buf1_avail)\n"
4852 "            buf1_written = buf1_avail = 0;\n"
4853 "        if (buf2_written == buf2_avail)\n"
4854 "            buf2_written = buf2_avail = 0;\n"
4855 msgstr ""
4856
4857 #. type: Plain text
4858 #: build/C/man2/select_tut.2:791
4859 #, no-wrap
4860 msgid ""
4861 "        /* one side has closed the connection, keep\n"
4862 "           writing to the other side until empty */\n"
4863 msgstr ""
4864
4865 #. type: Plain text
4866 #: build/C/man2/select_tut.2:799
4867 #, no-wrap
4868 msgid ""
4869 "        if (fd1 E<lt> 0 && buf1_avail - buf1_written == 0)\n"
4870 "            SHUT_FD2;\n"
4871 "        if (fd2 E<lt> 0 && buf2_avail - buf2_written == 0)\n"
4872 "            SHUT_FD1;\n"
4873 "    }\n"
4874 "    exit(EXIT_SUCCESS);\n"
4875 "}\n"
4876 msgstr ""
4877
4878 #. type: Plain text
4879 #: build/C/man2/select_tut.2:813
4880 msgid ""
4881 "The above program properly forwards most kinds of TCP connections including "
4882 "OOB signal data transmitted by B<telnet> servers.  It handles the tricky "
4883 "problem of having data flow in both directions simultaneously.  You might "
4884 "think it more efficient to use a B<fork>(2)  call and devote a thread to "
4885 "each stream.  This becomes more tricky than you might suspect.  Another idea "
4886 "is to set nonblocking I/O using B<fcntl>(2).  This also has its problems "
4887 "because you end up using inefficient timeouts."
4888 msgstr ""
4889
4890 #. type: Plain text
4891 #: build/C/man2/select_tut.2:819
4892 msgid ""
4893 "The program does not handle more than one simultaneous connection at a time, "
4894 "although it could easily be extended to do this with a linked list of "
4895 "buffers\\(emone for each connection.  At the moment, new connections cause "
4896 "the current connection to be dropped."
4897 msgstr ""
4898
4899 #.  .SH AUTHORS
4900 #.  This man page was written by Paul Sheer.
4901 #. type: Plain text
4902 #: build/C/man2/select_tut.2:838
4903 msgid ""
4904 "B<accept>(2), B<connect>(2), B<ioctl>(2), B<poll>(2), B<read>(2), "
4905 "B<recv>(2), B<select>(2), B<send>(2), B<sigprocmask>(2), B<write>(2), "
4906 "B<sigaddset>(3), B<sigdelset>(3), B<sigemptyset>(3), B<sigfillset>(3), "
4907 "B<sigismember>(3), B<epoll>(7)"
4908 msgstr ""
4909
4910 #. type: TH
4911 #: build/C/man2/send.2:40
4912 #, no-wrap
4913 msgid "SEND"
4914 msgstr ""
4915
4916 #. type: TH
4917 #: build/C/man2/send.2:40
4918 #, no-wrap
4919 msgid "2012-04-23"
4920 msgstr ""
4921
4922 #. type: Plain text
4923 #: build/C/man2/send.2:43
4924 msgid "send, sendto, sendmsg - send a message on a socket"
4925 msgstr ""
4926
4927 #. type: Plain text
4928 #: build/C/man2/send.2:47
4929 #, no-wrap
4930 msgid ""
4931 "B<#include E<lt>sys/types.hE<gt>>\n"
4932 "B<#include E<lt>sys/socket.hE<gt>>\n"
4933 msgstr ""
4934
4935 #. type: Plain text
4936 #: build/C/man2/send.2:50
4937 #, no-wrap
4938 msgid ""
4939 "B<ssize_t send(int >I<sockfd>B<, const void *>I<buf>B<, size_t >I<len>B<, "
4940 "int >I<flags>B<);>\n"
4941 msgstr ""
4942
4943 #. type: Plain text
4944 #: build/C/man2/send.2:54
4945 #, no-wrap
4946 msgid ""
4947 "B<ssize_t sendto(int >I<sockfd>B<, const void *>I<buf>B<, size_t >I<len>B<, "
4948 "int >I<flags>B<,>\n"
4949 "B<               const struct sockaddr *>I<dest_addr>B<, socklen_t "
4950 ">I<addrlen>B<);>\n"
4951 msgstr ""
4952
4953 #. type: Plain text
4954 #: build/C/man2/send.2:57
4955 #, no-wrap
4956 msgid ""
4957 "B<ssize_t sendmsg(int >I<sockfd>B<, const struct msghdr *>I<msg>B<, int "
4958 ">I<flags>B<);>\n"
4959 msgstr ""
4960
4961 #. type: Plain text
4962 #: build/C/man2/send.2:65
4963 msgid ""
4964 "The system calls B<send>(), B<sendto>(), and B<sendmsg>()  are used to "
4965 "transmit a message to another socket."
4966 msgstr ""
4967
4968 #. type: Plain text
4969 #: build/C/man2/send.2:84
4970 msgid ""
4971 "The B<send>()  call may be used only when the socket is in a I<connected> "
4972 "state (so that the intended recipient is known).  The only difference "
4973 "between B<send>()  and B<write>(2)  is the presence of I<flags>.  With a "
4974 "zero I<flags> argument, B<send>()  is equivalent to B<write>(2).  Also, the "
4975 "following call"
4976 msgstr ""
4977
4978 #. type: Plain text
4979 #: build/C/man2/send.2:86
4980 #, no-wrap
4981 msgid "    send(sockfd, buf, len, flags);\n"
4982 msgstr ""
4983
4984 #. type: Plain text
4985 #: build/C/man2/send.2:88
4986 msgid "is equivalent to"
4987 msgstr ""
4988
4989 #. type: Plain text
4990 #: build/C/man2/send.2:90
4991 #, no-wrap
4992 msgid "    sendto(sockfd, buf, len, flags, NULL, 0);\n"
4993 msgstr ""
4994
4995 #. type: Plain text
4996 #: build/C/man2/send.2:94
4997 msgid "The argument I<sockfd> is the file descriptor of the sending socket."
4998 msgstr ""
4999
5000 #. type: Plain text
5001 #: build/C/man2/send.2:122
5002 msgid ""
5003 "If B<sendto>()  is used on a connection-mode (B<SOCK_STREAM>, "
5004 "B<SOCK_SEQPACKET>)  socket, the arguments I<dest_addr> and I<addrlen> are "
5005 "ignored (and the error B<EISCONN> may be returned when they are not NULL and "
5006 "0), and the error B<ENOTCONN> is returned when the socket was not actually "
5007 "connected.  Otherwise, the address of the target is given by I<dest_addr> "
5008 "with I<addrlen> specifying its size.  For B<sendmsg>(), the address of the "
5009 "target is given by I<msg.msg_name>, with I<msg.msg_namelen> specifying its "
5010 "size."
5011 msgstr ""
5012
5013 #. type: Plain text
5014 #: build/C/man2/send.2:138
5015 msgid ""
5016 "For B<send>()  and B<sendto>(), the message is found in I<buf> and has "
5017 "length I<len>.  For B<sendmsg>(), the message is pointed to by the elements "
5018 "of the array I<msg.msg_iov>.  The B<sendmsg>()  call also allows sending "
5019 "ancillary data (also known as control information)."
5020 msgstr ""
5021
5022 #. type: Plain text
5023 #: build/C/man2/send.2:143
5024 msgid ""
5025 "If the message is too long to pass atomically through the underlying "
5026 "protocol, the error B<EMSGSIZE> is returned, and the message is not "
5027 "transmitted."
5028 msgstr ""
5029
5030 #. type: Plain text
5031 #: build/C/man2/send.2:147
5032 msgid ""
5033 "No indication of failure to deliver is implicit in a B<send>().  Locally "
5034 "detected errors are indicated by a return value of -1."
5035 msgstr ""
5036
5037 #. type: Plain text
5038 #: build/C/man2/send.2:160
5039 msgid ""
5040 "When the message does not fit into the send buffer of the socket, B<send>()  "
5041 "normally blocks, unless the socket has been placed in nonblocking I/O mode.  "
5042 "In nonblocking mode it would fail with the error B<EAGAIN> or B<EWOULDBLOCK> "
5043 "in this case.  The B<select>(2)  call may be used to determine when it is "
5044 "possible to send more data."
5045 msgstr ""
5046
5047 #.  FIXME ? document MSG_PROXY (which went away in 2.3.15)
5048 #. type: Plain text
5049 #: build/C/man2/send.2:166
5050 msgid ""
5051 "The I<flags> argument is the bitwise OR of zero or more of the following "
5052 "flags."
5053 msgstr ""
5054
5055 #. type: TP
5056 #: build/C/man2/send.2:166
5057 #, no-wrap
5058 msgid "B<MSG_CONFIRM> (Since Linux 2.3.15)"
5059 msgstr ""
5060
5061 #. type: Plain text
5062 #: build/C/man2/send.2:180
5063 msgid ""
5064 "Tell the link layer that forward progress happened: you got a successful "
5065 "reply from the other side.  If the link layer doesn't get this it will "
5066 "regularly reprobe the neighbor (e.g., via a unicast ARP).  Only valid on "
5067 "B<SOCK_DGRAM> and B<SOCK_RAW> sockets and currently only implemented for "
5068 "IPv4 and IPv6.  See B<arp>(7)  for details."
5069 msgstr ""
5070
5071 #. type: TP
5072 #: build/C/man2/send.2:180
5073 #, no-wrap
5074 msgid "B<MSG_DONTROUTE>"
5075 msgstr ""
5076
5077 #. type: Plain text
5078 #: build/C/man2/send.2:188
5079 msgid ""
5080 "Don't use a gateway to send out the packet, only send to hosts on directly "
5081 "connected networks.  This is usually used only by diagnostic or routing "
5082 "programs.  This is only defined for protocol families that route; packet "
5083 "sockets don't."
5084 msgstr ""
5085
5086 #. type: Plain text
5087 #: build/C/man2/send.2:199
5088 msgid ""
5089 "Enables nonblocking operation; if the operation would block, B<EAGAIN> or "
5090 "B<EWOULDBLOCK> is returned (this can also be enabled using the B<O_NONBLOCK> "
5091 "flag with the B<F_SETFL> B<fcntl>(2))."
5092 msgstr ""
5093
5094 #. type: TP
5095 #: build/C/man2/send.2:199
5096 #, no-wrap
5097 msgid "B<MSG_EOR> (since Linux 2.2)"
5098 msgstr ""
5099
5100 #. type: Plain text
5101 #: build/C/man2/send.2:203
5102 msgid ""
5103 "Terminates a record (when this notion is supported, as for sockets of type "
5104 "B<SOCK_SEQPACKET>)."
5105 msgstr ""
5106
5107 #. type: TP
5108 #: build/C/man2/send.2:203
5109 #, no-wrap
5110 msgid "B<MSG_MORE> (Since Linux 2.4.4)"
5111 msgstr ""
5112
5113 #. type: Plain text
5114 #: build/C/man2/send.2:212
5115 msgid ""
5116 "The caller has more data to send.  This flag is used with TCP sockets to "
5117 "obtain the same effect as the B<TCP_CORK> socket option (see B<tcp>(7)), "
5118 "with the difference that this flag can be set on a per-call basis."
5119 msgstr ""
5120
5121 #. type: Plain text
5122 #: build/C/man2/send.2:221
5123 msgid ""
5124 "Since Linux 2.6, this flag is also supported for UDP sockets, and informs "
5125 "the kernel to package all of the data sent in calls with this flag set into "
5126 "a single datagram which is only transmitted when a call is performed that "
5127 "does not specify this flag.  (See also the B<UDP_CORK> socket option "
5128 "described in B<udp>(7).)"
5129 msgstr ""
5130
5131 #. type: TP
5132 #: build/C/man2/send.2:221
5133 #, no-wrap
5134 msgid "B<MSG_NOSIGNAL> (since Linux 2.2)"
5135 msgstr ""
5136
5137 #. type: Plain text
5138 #: build/C/man2/send.2:230
5139 msgid ""
5140 "Requests not to send B<SIGPIPE> on errors on stream oriented sockets when "
5141 "the other end breaks the connection.  The B<EPIPE> error is still returned."
5142 msgstr ""
5143
5144 #. type: Plain text
5145 #: build/C/man2/send.2:239
5146 msgid ""
5147 "Sends I<out-of-band> data on sockets that support this notion (e.g., of type "
5148 "B<SOCK_STREAM>); the underlying protocol must also support I<out-of-band> "
5149 "data."
5150 msgstr ""
5151
5152 #. type: Plain text
5153 #: build/C/man2/send.2:246
5154 msgid ""
5155 "The definition of the I<msghdr> structure follows.  See B<recv>(2)  and "
5156 "below for an exact description of its fields."
5157 msgstr ""
5158
5159 #.  Still to be documented:
5160 #.   Send file descriptors and user credentials using the
5161 #.   msg_control* fields.
5162 #.   The flags returned in msg_flags.
5163 #. type: Plain text
5164 #: build/C/man2/send.2:275
5165 msgid ""
5166 "You may send control information using the I<msg_control> and "
5167 "I<msg_controllen> members.  The maximum control buffer length the kernel can "
5168 "process is limited per socket by the value in "
5169 "I</proc/sys/net/core/optmem_max>; see B<socket>(7)."
5170 msgstr ""
5171
5172 #. type: Plain text
5173 #: build/C/man2/send.2:280
5174 msgid ""
5175 "On success, these calls return the number of characters sent.  On error, -1 "
5176 "is returned, and I<errno> is set appropriately."
5177 msgstr ""
5178
5179 #. type: Plain text
5180 #: build/C/man2/send.2:285
5181 msgid ""
5182 "These are some standard errors generated by the socket layer.  Additional "
5183 "errors may be generated and returned from the underlying protocol modules; "
5184 "see their respective manual pages."
5185 msgstr ""
5186
5187 #. type: Plain text
5188 #: build/C/man2/send.2:293
5189 msgid ""
5190 "(For UNIX domain sockets, which are identified by pathname)  Write "
5191 "permission is denied on the destination socket file, or search permission is "
5192 "denied for one of the directories the path prefix.  (See "
5193 "B<path_resolution>(7).)"
5194 msgstr ""
5195
5196 #. type: Plain text
5197 #: build/C/man2/send.2:296
5198 msgid ""
5199 "(For UDP sockets) An attempt was made to send to a network/broadcast address "
5200 "as though it was a unicast address."
5201 msgstr ""
5202
5203 #.  Actually EAGAIN on Linux
5204 #. type: Plain text
5205 #: build/C/man2/send.2:304
5206 msgid ""
5207 "The socket is marked nonblocking and the requested operation would block.  "
5208 "POSIX.1-2001 allows either error to be returned for this case, and does not "
5209 "require these constants to have the same value, so a portable application "
5210 "should check for both possibilities."
5211 msgstr ""
5212
5213 #. type: Plain text
5214 #: build/C/man2/send.2:307
5215 msgid "An invalid descriptor was specified."
5216 msgstr ""
5217
5218 #. type: TP
5219 #: build/C/man2/send.2:307
5220 #, no-wrap
5221 msgid "B<ECONNRESET>"
5222 msgstr ""
5223
5224 #. type: Plain text
5225 #: build/C/man2/send.2:310
5226 msgid "Connection reset by peer."
5227 msgstr ""
5228
5229 #. type: TP
5230 #: build/C/man2/send.2:310
5231 #, no-wrap
5232 msgid "B<EDESTADDRREQ>"
5233 msgstr ""
5234
5235 #. type: Plain text
5236 #: build/C/man2/send.2:313
5237 msgid "The socket is not connection-mode, and no peer address is set."
5238 msgstr ""
5239
5240 #. type: Plain text
5241 #: build/C/man2/send.2:316
5242 msgid "An invalid user space address was specified for an argument."
5243 msgstr ""
5244
5245 #. type: Plain text
5246 #: build/C/man2/send.2:320
5247 msgid "A signal occurred before any data was transmitted; see B<signal>(7)."
5248 msgstr ""
5249
5250 #. type: Plain text
5251 #: build/C/man2/send.2:329
5252 msgid ""
5253 "The connection-mode socket was connected already but a recipient was "
5254 "specified.  (Now either this error is returned, or the recipient "
5255 "specification is ignored.)"
5256 msgstr ""
5257
5258 #. type: TP
5259 #: build/C/man2/send.2:329
5260 #, no-wrap
5261 msgid "B<EMSGSIZE>"
5262 msgstr ""
5263
5264 #.  (e.g., SOCK_DGRAM )
5265 #. type: Plain text
5266 #: build/C/man2/send.2:335
5267 msgid ""
5268 "The socket type requires that message be sent atomically, and the size of "
5269 "the message to be sent made this impossible."
5270 msgstr ""
5271
5272 #. type: Plain text
5273 #: build/C/man2/send.2:343
5274 msgid ""
5275 "The output queue for a network interface was full.  This generally indicates "
5276 "that the interface has stopped sending, but may be caused by transient "
5277 "congestion.  (Normally, this does not occur in Linux.  Packets are just "
5278 "silently dropped when a device queue overflows.)"
5279 msgstr ""
5280
5281 #. type: Plain text
5282 #: build/C/man2/send.2:346
5283 msgid "No memory available."
5284 msgstr ""
5285
5286 #. type: Plain text
5287 #: build/C/man2/send.2:349
5288 msgid "The socket is not connected, and no target has been given."
5289 msgstr ""
5290
5291 #. type: Plain text
5292 #: build/C/man2/send.2:359
5293 msgid "Some bit in the I<flags> argument is inappropriate for the socket type."
5294 msgstr ""
5295
5296 #. type: TP
5297 #: build/C/man2/send.2:359
5298 #, no-wrap
5299 msgid "B<EPIPE>"
5300 msgstr ""
5301
5302 #. type: Plain text
5303 #: build/C/man2/send.2:368
5304 msgid ""
5305 "The local end has been shut down on a connection oriented socket.  In this "
5306 "case the process will also receive a B<SIGPIPE> unless B<MSG_NOSIGNAL> is "
5307 "set."
5308 msgstr ""
5309
5310 #. type: Plain text
5311 #: build/C/man2/send.2:371
5312 msgid "4.4BSD, SVr4, POSIX.1-2001.  These function calls appeared in 4.2BSD."
5313 msgstr ""
5314
5315 #. type: Plain text
5316 #: build/C/man2/send.2:382
5317 msgid ""
5318 "POSIX.1-2001 only describes the B<MSG_OOB> and B<MSG_EOR> flags.  "
5319 "POSIX.1-2008 adds a specification of B<MSG_NOSIGNAL>.  The B<MSG_CONFIRM> "
5320 "flag is a Linux extension."
5321 msgstr ""
5322
5323 #. type: Plain text
5324 #: build/C/man2/send.2:395
5325 msgid ""
5326 "The prototypes given above follow the Single UNIX Specification, as glibc2 "
5327 "also does; the I<flags> argument was I<int> in 4.x BSD, but I<unsigned int> "
5328 "in libc4 and libc5; the I<len> argument was I<int> in 4.x BSD and libc4, but "
5329 "I<size_t> in libc5; the I<addrlen> argument was I<int> in 4.x BSD and libc4 "
5330 "and libc5.  See also B<accept>(2)."
5331 msgstr ""
5332
5333 #. type: Plain text
5334 #: build/C/man2/send.2:414
5335 msgid ""
5336 "See B<sendmmsg>(2)  for information about a Linux-specific system call that "
5337 "can be used to transmit multiple datagrams in a single call."
5338 msgstr ""
5339
5340 #. type: Plain text
5341 #: build/C/man2/send.2:419
5342 msgid "Linux may return B<EPIPE> instead of B<ENOTCONN>."
5343 msgstr ""
5344
5345 #. type: Plain text
5346 #: build/C/man2/send.2:424
5347 msgid "An example of the use of B<sendto>()  is shown in B<getaddrinfo>(3)."
5348 msgstr ""
5349
5350 #. type: Plain text
5351 #: build/C/man2/send.2:439
5352 msgid ""
5353 "B<fcntl>(2), B<getsockopt>(2), B<recv>(2), B<select>(2), B<sendfile>(2), "
5354 "B<sendmmsg>(2), B<shutdown>(2), B<socket>(2), B<write>(2), B<cmsg>(3), "
5355 "B<ip>(7), B<socket>(7), B<tcp>(7), B<udp>(7)"
5356 msgstr ""
5357
5358 #. type: TH
5359 #: build/C/man2/sendmmsg.2:28
5360 #, no-wrap
5361 msgid "SENDMMSG"
5362 msgstr ""
5363
5364 #. type: TH
5365 #: build/C/man2/sendmmsg.2:28
5366 #, no-wrap
5367 msgid "2012-12-16"
5368 msgstr ""
5369
5370 #. type: Plain text
5371 #: build/C/man2/sendmmsg.2:31
5372 msgid "sendmmsg - send multiple messages on a socket"
5373 msgstr ""
5374
5375 #. type: Plain text
5376 #: build/C/man2/sendmmsg.2:39
5377 #, no-wrap
5378 msgid ""
5379 "B<int sendmmsg(int >I<sockfd>B<, struct mmsghdr *>I<msgvec>B<, unsigned int "
5380 ">I<vlen>B<,>\n"
5381 "B<             unsigned int >I<flags>B<);>\n"
5382 msgstr ""
5383
5384 #.  See commit 228e548e602061b08ee8e8966f567c12aa079682
5385 #. type: Plain text
5386 #: build/C/man2/sendmmsg.2:49
5387 msgid ""
5388 "The B<sendmmsg>()  system call is an extension of B<sendmsg>(2)  that allows "
5389 "the caller to transmit multiple messages on a socket using a single system "
5390 "call.  (This has performance benefits for some applications.)"
5391 msgstr ""
5392
5393 #. type: Plain text
5394 #: build/C/man2/sendmmsg.2:54
5395 msgid ""
5396 "The I<sockfd> argument is the file descriptor of the socket on which data is "
5397 "to be transmitted."
5398 msgstr ""
5399
5400 #. type: Plain text
5401 #: build/C/man2/sendmmsg.2:75
5402 #, no-wrap
5403 msgid ""
5404 "struct mmsghdr {\n"
5405 "    struct msghdr msg_hdr;  /* Message header */\n"
5406 "    unsigned int  msg_len;  /* Number of bytes transmitted */\n"
5407 "};\n"
5408 msgstr ""
5409
5410 #. type: Plain text
5411 #: build/C/man2/sendmmsg.2:91
5412 msgid ""
5413 "The I<msg_hdr> field is a I<msghdr> structure, as described in "
5414 "B<sendmsg>(2).  The I<msg_len> field is used to return the number of bytes "
5415 "sent from the message in I<msg_hdr> (i.e., the same as the return value from "
5416 "a single B<sendmsg>(2)  call)."
5417 msgstr ""
5418
5419 #. type: Plain text
5420 #: build/C/man2/sendmmsg.2:97
5421 msgid ""
5422 "The I<flags> argument contains flags ORed together.  The flags are the same "
5423 "as for B<sendmsg>(2)."
5424 msgstr ""
5425
5426 #. type: Plain text
5427 #: build/C/man2/sendmmsg.2:107
5428 msgid ""
5429 "A blocking B<sendmmsg>()  call blocks until I<vlen> messages have been "
5430 "sent.  A nonblocking call sends as many messages as possible (up to the "
5431 "limit specified by I<vlen>)  and returns immediately."
5432 msgstr ""
5433
5434 #. type: Plain text
5435 #: build/C/man2/sendmmsg.2:119
5436 msgid ""
5437 "On return from B<sendmmsg>(), the I<msg_len> fields of successive elements "
5438 "of I<msgvec> are updated to contain the number of bytes transmitted from the "
5439 "corresponding I<msg_hdr>.  The return value of the call indicates the number "
5440 "of elements of I<msgvec> that have been updated."
5441 msgstr ""
5442
5443 #. type: Plain text
5444 #: build/C/man2/sendmmsg.2:129
5445 msgid ""
5446 "On success, B<sendmmsg>()  returns the number of messages sent from "
5447 "I<msgvec>; if this is less than I<vlen>, the caller can retry with a further "
5448 "B<sendmmsg>()  call to send the remaining messages."
5449 msgstr ""
5450
5451 #. type: Plain text
5452 #: build/C/man2/sendmmsg.2:133
5453 msgid "On error, -1 is returned, and I<errno> is set to indicate the error."
5454 msgstr ""
5455
5456 #.  commit 728ffb86f10873aaf4abd26dde691ee40ae731fe
5457 #.      ... only return an error if no datagrams could be sent.
5458 #.      If less than the requested number of messages were sent, the application
5459 #.      must retry starting at the first failed one and if the problem is
5460 #.      persistent the error will be returned.
5461 #
5462 #.      This matches the behaviour of other syscalls like read/write - it
5463 #.      is not an error if less than the requested number of elements are sent.
5464 #. type: Plain text
5465 #: build/C/man2/sendmmsg.2:145
5466 msgid ""
5467 "Errors are as for B<sendmsg>(2).  An error is returned only if no datagrams "
5468 "could be sent."
5469 msgstr ""
5470
5471 #. type: Plain text
5472 #: build/C/man2/sendmmsg.2:150
5473 msgid ""
5474 "The B<sendmmsg>()  system call was added in Linux 3.0.  Support in glibc was "
5475 "added in version 2.14."
5476 msgstr ""
5477
5478 #. type: Plain text
5479 #: build/C/man2/sendmmsg.2:153
5480 msgid "B<sendmmsg>()  is Linux-specific."
5481 msgstr ""
5482
5483 #.  commit 98382f419f32d2c12d021943b87dea555677144b
5484 #.      net: Cap number of elements for sendmmsg
5485 #
5486 #.      To limit the amount of time we can spend in sendmmsg, cap the
5487 #.      number of elements to UIO_MAXIOV (currently 1024).
5488 #
5489 #.      For error handling an application using sendmmsg needs to retry at
5490 #.      the first unsent message, so capping is simpler and requires less
5491 #.      application logic than returning EINVAL.
5492 #. type: Plain text
5493 #: build/C/man2/sendmmsg.2:168
5494 msgid "The value specified in I<vlen> is capped to B<UIO_MAXIOV> (1024)."
5495 msgstr ""
5496
5497 #. type: Plain text
5498 #: build/C/man2/sendmmsg.2:177
5499 msgid ""
5500 "The example below uses B<sendmmsg>()  to send I<onetwo> and I<three> in two "
5501 "distinct UDP datagrams using one system call.  The contents of the first "
5502 "datagram originates from a pair of buffers."
5503 msgstr ""
5504
5505 #. type: Plain text
5506 #: build/C/man2/sendmmsg.2:186
5507 #, no-wrap
5508 msgid ""
5509 "#define _GNU_SOURCE\n"
5510 "#include E<lt>netinet/ip.hE<gt>\n"
5511 "#include E<lt>stdio.hE<gt>\n"
5512 "#include E<lt>stdlib.hE<gt>\n"
5513 "#include E<lt>string.hE<gt>\n"
5514 "#include E<lt>sys/types.hE<gt>\n"
5515 "#include E<lt>sys/socket.hE<gt>\n"
5516 msgstr ""
5517
5518 #. type: Plain text
5519 #: build/C/man2/sendmmsg.2:195
5520 #, no-wrap
5521 msgid ""
5522 "int\n"
5523 "main(void)\n"
5524 "{\n"
5525 "    int sockfd;\n"
5526 "    struct sockaddr_in sa;\n"
5527 "    struct mmsghdr msg[2];\n"
5528 "    struct iovec msg1[2], msg2;\n"
5529 "    int retval;\n"
5530 msgstr ""
5531
5532 #. type: Plain text
5533 #: build/C/man2/sendmmsg.2:209
5534 #, no-wrap
5535 msgid ""
5536 "    sa.sin_family = AF_INET;\n"
5537 "    sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK);\n"
5538 "    sa.sin_port = htons(1234);\n"
5539 "    if (connect(sockfd, (struct sockaddr *) &sa, sizeof(sa)) == -1) {\n"
5540 "        perror(\"connect()\");\n"
5541 "        exit(EXIT_FAILURE);\n"
5542 "    }\n"
5543 msgstr ""
5544
5545 #. type: Plain text
5546 #: build/C/man2/sendmmsg.2:215
5547 #, no-wrap
5548 msgid ""
5549 "    memset(msg1, 0, sizeof(msg1));\n"
5550 "    msg1[0].iov_base = \"one\";\n"
5551 "    msg1[0].iov_len = 3;\n"
5552 "    msg1[1].iov_base = \"two\";\n"
5553 "    msg1[1].iov_len = 3;\n"
5554 msgstr ""
5555
5556 #. type: Plain text
5557 #: build/C/man2/sendmmsg.2:219
5558 #, no-wrap
5559 msgid ""
5560 "    memset(&msg2, 0, sizeof(msg2));\n"
5561 "    msg2.iov_base = \"three\";\n"
5562 "    msg2.iov_len = 5;\n"
5563 msgstr ""
5564
5565 #. type: Plain text
5566 #: build/C/man2/sendmmsg.2:223
5567 #, no-wrap
5568 msgid ""
5569 "    memset(msg, 0, sizeof(msg));\n"
5570 "    msg[0].msg_hdr.msg_iov = msg1;\n"
5571 "    msg[0].msg_hdr.msg_iovlen = 2;\n"
5572 msgstr ""
5573
5574 #. type: Plain text
5575 #: build/C/man2/sendmmsg.2:226
5576 #, no-wrap
5577 msgid ""
5578 "    msg[1].msg_hdr.msg_iov = &msg2;\n"
5579 "    msg[1].msg_hdr.msg_iovlen = 1;\n"
5580 msgstr ""
5581
5582 #. type: Plain text
5583 #: build/C/man2/sendmmsg.2:232
5584 #, no-wrap
5585 msgid ""
5586 "    retval = sendmmsg(sockfd, msg, 2, 0);\n"
5587 "    if (retval == -1)\n"
5588 "        perror(\"sendmmsg()\");\n"
5589 "    else\n"
5590 "        printf(\"%d messages sent\\en\", retval);\n"
5591 msgstr ""
5592
5593 #. type: Plain text
5594 #: build/C/man2/sendmmsg.2:235
5595 #, no-wrap
5596 msgid ""
5597 "    exit(0);\n"
5598 "}\n"
5599 msgstr ""
5600
5601 #. type: Plain text
5602 #: build/C/man2/sendmmsg.2:241
5603 msgid "B<recvmmsg>(2), B<sendmsg>(2), B<socket>(2), B<socket>(7)"
5604 msgstr ""
5605
5606 #. type: TH
5607 #: build/C/man3/sockatmark.3:25
5608 #, no-wrap
5609 msgid "SOCKATMARK"
5610 msgstr ""
5611
5612 #. type: Plain text
5613 #: build/C/man3/sockatmark.3:28
5614 msgid "sockatmark - determine whether socket is at out-of-band mark"
5615 msgstr ""
5616
5617 #. type: Plain text
5618 #: build/C/man3/sockatmark.3:30 build/C/man2/socket.2:50 build/C/man7/socket.7:53 build/C/man2/socketpair.2:49
5619 msgid "B<#include E<lt>sys/socket.hE<gt>>"
5620 msgstr ""
5621
5622 #. type: Plain text
5623 #: build/C/man3/sockatmark.3:32
5624 msgid "B<int sockatmark(int >I<sockfd>B<);>"
5625 msgstr ""
5626
5627 #. type: Plain text
5628 #: build/C/man3/sockatmark.3:41
5629 msgid ""
5630 "B<sockatmark>(): _POSIX_C_SOURCE\\ E<gt>=\\ 200112L || _XOPEN_SOURCE\\ "
5631 "E<gt>=\\ 600"
5632 msgstr ""
5633
5634 #. type: Plain text
5635 #: build/C/man3/sockatmark.3:51
5636 msgid ""
5637 "B<sockatmark>()  returns a value indicating whether or not the socket "
5638 "referred to by the file descriptor I<sockfd> is at the out-of-band mark.  If "
5639 "the socket is at the mark, then 1 is returned; if the socket is not at the "
5640 "mark, 0 is returned.  This function does not remove the out-of-band mark."
5641 msgstr ""
5642
5643 #. type: Plain text
5644 #: build/C/man3/sockatmark.3:56
5645 msgid ""
5646 "A successful call to B<sockatmark>()  returns 1 if the socket is at the "
5647 "out-of-band mark, or 0 if it is not.  On error, -1 is returned and I<errno> "
5648 "is set to indicate the error."
5649 msgstr ""
5650
5651 #. type: Plain text
5652 #: build/C/man3/sockatmark.3:61
5653 msgid "I<sockfd> is not a valid file descriptor."
5654 msgstr ""
5655
5656 #.  POSIX.1 says ENOTTY for this case
5657 #. type: Plain text
5658 #: build/C/man3/sockatmark.3:68
5659 msgid "I<sockfd> is not a file descriptor to which B<sockatmark>()  can be applied."
5660 msgstr ""
5661
5662 #. type: Plain text
5663 #: build/C/man3/sockatmark.3:71
5664 msgid "B<sockatmark>()  was added to glibc in version 2.2.4."
5665 msgstr ""
5666
5667 #. type: Plain text
5668 #: build/C/man3/sockatmark.3:73
5669 msgid "POSIX.1-2001."
5670 msgstr ""
5671
5672 #. type: Plain text
5673 #: build/C/man3/sockatmark.3:80
5674 msgid ""
5675 "If B<sockatmark>()  returns 1, then the out-of-band data can be read using "
5676 "the B<MSG_OOB> flag of B<recv>(2)."
5677 msgstr ""
5678
5679 #. type: Plain text
5680 #: build/C/man3/sockatmark.3:82
5681 msgid "Out-of-band data is only supported on some stream socket protocols."
5682 msgstr ""
5683
5684 #. type: Plain text
5685 #: build/C/man3/sockatmark.3:87
5686 msgid ""
5687 "B<sockatmark>()  can safely be called from a handler for the B<SIGURG> "
5688 "signal."
5689 msgstr ""
5690
5691 #. type: Plain text
5692 #: build/C/man3/sockatmark.3:93
5693 msgid ""
5694 "B<sockatmark>()  is implemented using the B<SIOCATMARK> B<ioctl>(2)  "
5695 "operation."
5696 msgstr ""
5697
5698 #. type: Plain text
5699 #: build/C/man3/sockatmark.3:97
5700 msgid "Prior to glibc 2.4, B<sockatmark>()  did not work."
5701 msgstr ""
5702
5703 #. type: Plain text
5704 #: build/C/man3/sockatmark.3:102
5705 msgid ""
5706 "The following code can be used after receipt of a B<SIGURG> signal to read "
5707 "(and discard) all data up to the mark, and then read the byte of data at the "
5708 "mark:"
5709 msgstr ""
5710
5711 #. type: Plain text
5712 #: build/C/man3/sockatmark.3:107
5713 #, no-wrap
5714 msgid ""
5715 "    char buf[BUF_LEN];\n"
5716 "    char oobdata;\n"
5717 "    int atmark, s;\n"
5718 msgstr ""
5719
5720 #. type: Plain text
5721 #: build/C/man3/sockatmark.3:114
5722 #, no-wrap
5723 msgid ""
5724 "    for (;;) {\n"
5725 "        atmark = sockatmark(sockfd);\n"
5726 "        if (atmark == -1) {\n"
5727 "            perror(\"sockatmark\");\n"
5728 "            break;\n"
5729 "        }\n"
5730 msgstr ""
5731
5732 #. type: Plain text
5733 #: build/C/man3/sockatmark.3:117
5734 #, no-wrap
5735 msgid ""
5736 "        if (atmark)\n"
5737 "            break;\n"
5738 msgstr ""
5739
5740 #. type: Plain text
5741 #: build/C/man3/sockatmark.3:124
5742 #, no-wrap
5743 msgid ""
5744 "        s = read(sockfd, buf, BUF_LEN) E<lt>= 0);\n"
5745 "        if (s == -1)\n"
5746 "            perror(\"read\");\n"
5747 "        if (s E<lt>= 0)\n"
5748 "            break;\n"
5749 "    }\n"
5750 msgstr ""
5751
5752 #. type: Plain text
5753 #: build/C/man3/sockatmark.3:131
5754 #, no-wrap
5755 msgid ""
5756 "    if (atmark == 1) {\n"
5757 "        if (recv(sockfd, &oobdata, 1, MSG_OOB) == -1) {\n"
5758 "            perror(\"recv\");\n"
5759 "            ...\n"
5760 "        }\n"
5761 "    }\n"
5762 msgstr ""
5763
5764 #. type: Plain text
5765 #: build/C/man3/sockatmark.3:137
5766 msgid "B<fcntl>(2), B<recv>(2), B<send>(2), B<tcp>(7)"
5767 msgstr ""
5768
5769 #. type: TH
5770 #: build/C/man2/socket.2:43 build/C/man7/socket.7:48
5771 #, no-wrap
5772 msgid "SOCKET"
5773 msgstr ""
5774
5775 #. type: TH
5776 #: build/C/man2/socket.2:43
5777 #, no-wrap
5778 msgid "2009-01-19"
5779 msgstr ""
5780
5781 #. type: Plain text
5782 #: build/C/man2/socket.2:46
5783 msgid "socket - create an endpoint for communication"
5784 msgstr ""
5785
5786 #. type: Plain text
5787 #: build/C/man2/socket.2:48 build/C/man2/socketpair.2:47
5788 msgid "B<#include E<lt>sys/types.hE<gt>> /* See NOTES */"
5789 msgstr ""
5790
5791 #. type: Plain text
5792 #: build/C/man2/socket.2:52
5793 msgid "B<int socket(int >I<domain>B<, int >I<type>B<, int >I<protocol>B<);>"
5794 msgstr ""
5795
5796 #. type: Plain text
5797 #: build/C/man2/socket.2:55
5798 msgid "B<socket>()  creates an endpoint for communication and returns a descriptor."
5799 msgstr ""
5800
5801 #. type: Plain text
5802 #: build/C/man2/socket.2:63
5803 msgid ""
5804 "The I<domain> argument specifies a communication domain; this selects the "
5805 "protocol family which will be used for communication.  These families are "
5806 "defined in I<E<lt>sys/socket.hE<gt>>.  The currently understood formats "
5807 "include:"
5808 msgstr ""
5809
5810 #. type: tbl table
5811 #: build/C/man2/socket.2:66
5812 #, no-wrap
5813 msgid "Name:Purpose:Man page\n"
5814 msgstr ""
5815
5816 #. type: tbl table
5817 #: build/C/man2/socket.2:67 build/C/man2/socket.2:74 build/C/man2/socket.2:79 build/C/man2/socket.2:84 build/C/man2/socket.2:87 build/C/man2/socket.2:94 build/C/man2/socket.2:99 build/C/man2/socket.2:104 build/C/man2/socket.2:107 build/C/man2/socket.2:112
5818 #, no-wrap
5819 msgid "T{\n"
5820 msgstr ""
5821
5822 #. type: tbl table
5823 #: build/C/man2/socket.2:68
5824 #, no-wrap
5825 msgid "B<AF_UNIX>, B<AF_LOCAL>\n"
5826 msgstr ""
5827
5828 #. type: tbl table
5829 #: build/C/man2/socket.2:69 build/C/man2/socket.2:71 build/C/man2/socket.2:89 build/C/man2/socket.2:91 build/C/man2/socket.2:101 build/C/man2/socket.2:114 build/C/man2/socket.2:116 build/C/man7/socket.7:184
5830 #, no-wrap
5831 msgid "T}:T{\n"
5832 msgstr ""
5833
5834 #. type: tbl table
5835 #: build/C/man2/socket.2:70
5836 #, no-wrap
5837 msgid "Local communication\n"
5838 msgstr ""
5839
5840 #. type: tbl table
5841 #: build/C/man2/socket.2:72
5842 #, no-wrap
5843 msgid "B<unix>(7)\n"
5844 msgstr ""
5845
5846 #. type: tbl table
5847 #: build/C/man2/socket.2:73 build/C/man2/socket.2:78 build/C/man2/socket.2:83 build/C/man2/socket.2:93 build/C/man2/socket.2:98 build/C/man2/socket.2:111 build/C/man2/socket.2:118 build/C/man7/socket.7:163 build/C/man7/socket.7:167 build/C/man7/socket.7:170 build/C/man7/socket.7:176 build/C/man7/socket.7:179 build/C/man7/socket.7:188 build/C/man7/socket.7:195
5848 #, no-wrap
5849 msgid "T}\n"
5850 msgstr ""
5851
5852 #. type: tbl table
5853 #: build/C/man2/socket.2:75
5854 #, no-wrap
5855 msgid "B<AF_INET>\n"
5856 msgstr ""
5857
5858 #. type: tbl table
5859 #: build/C/man2/socket.2:76
5860 #, no-wrap
5861 msgid "T}:IPv4 Internet protocols:T{\n"
5862 msgstr ""
5863
5864 #. type: tbl table
5865 #: build/C/man2/socket.2:77
5866 #, no-wrap
5867 msgid "B<ip>(7)\n"
5868 msgstr ""
5869
5870 #. type: tbl table
5871 #: build/C/man2/socket.2:80
5872 #, no-wrap
5873 msgid "B<AF_INET6>\n"
5874 msgstr ""
5875
5876 #. type: tbl table
5877 #: build/C/man2/socket.2:81
5878 #, no-wrap
5879 msgid "T}:IPv6 Internet protocols:T{\n"
5880 msgstr ""
5881
5882 #. type: tbl table
5883 #: build/C/man2/socket.2:82
5884 #, no-wrap
5885 msgid "B<ipv6>(7)\n"
5886 msgstr ""
5887
5888 #. type: tbl table
5889 #: build/C/man2/socket.2:85
5890 #, no-wrap
5891 msgid "B<AF_IPX>\n"
5892 msgstr ""
5893
5894 #. type: tbl table
5895 #: build/C/man2/socket.2:86
5896 #, no-wrap
5897 msgid "T}:IPX - Novell protocols:\n"
5898 msgstr ""
5899
5900 #. type: tbl table
5901 #: build/C/man2/socket.2:88
5902 #, no-wrap
5903 msgid "B<AF_NETLINK>\n"
5904 msgstr ""
5905
5906 #. type: tbl table
5907 #: build/C/man2/socket.2:90
5908 #, no-wrap
5909 msgid "Kernel user interface device\n"
5910 msgstr ""
5911
5912 #. type: tbl table
5913 #: build/C/man2/socket.2:92
5914 #, no-wrap
5915 msgid "B<netlink>(7)\n"
5916 msgstr ""
5917
5918 #. type: tbl table
5919 #: build/C/man2/socket.2:95
5920 #, no-wrap
5921 msgid "B<AF_X25>\n"
5922 msgstr ""
5923
5924 #. type: tbl table
5925 #: build/C/man2/socket.2:96
5926 #, no-wrap
5927 msgid "T}:ITU-T X.25 / ISO-8208 protocol:T{\n"
5928 msgstr ""
5929
5930 #. type: tbl table
5931 #: build/C/man2/socket.2:97
5932 #, no-wrap
5933 msgid "B<x25>(7)\n"
5934 msgstr ""
5935
5936 #. type: tbl table
5937 #: build/C/man2/socket.2:100
5938 #, no-wrap
5939 msgid "B<AF_AX25>\n"
5940 msgstr ""
5941
5942 #. type: tbl table
5943 #: build/C/man2/socket.2:102
5944 #, no-wrap
5945 msgid "Amateur radio AX.25 protocol\n"
5946 msgstr ""
5947
5948 #. type: tbl table
5949 #: build/C/man2/socket.2:103
5950 #, no-wrap
5951 msgid "T}:\n"
5952 msgstr ""
5953
5954 #. type: tbl table
5955 #: build/C/man2/socket.2:105
5956 #, no-wrap
5957 msgid "B<AF_ATMPVC>\n"
5958 msgstr ""
5959
5960 #. type: tbl table
5961 #: build/C/man2/socket.2:106
5962 #, no-wrap
5963 msgid "T}:Access to raw ATM PVCs:\n"
5964 msgstr ""
5965
5966 #. type: tbl table
5967 #: build/C/man2/socket.2:108
5968 #, no-wrap
5969 msgid "B<AF_APPLETALK>\n"
5970 msgstr ""
5971
5972 #. type: tbl table
5973 #: build/C/man2/socket.2:109
5974 #, no-wrap
5975 msgid "T}:Appletalk:T{\n"
5976 msgstr ""
5977
5978 #. type: tbl table
5979 #: build/C/man2/socket.2:110
5980 #, no-wrap
5981 msgid "B<ddp>(7)\n"
5982 msgstr ""
5983
5984 #. type: tbl table
5985 #: build/C/man2/socket.2:113
5986 #, no-wrap
5987 msgid "B<AF_PACKET>\n"
5988 msgstr ""
5989
5990 #. type: tbl table
5991 #: build/C/man2/socket.2:115
5992 #, no-wrap
5993 msgid "Low level packet interface\n"
5994 msgstr ""
5995
5996 #. type: tbl table
5997 #: build/C/man2/socket.2:117
5998 #, no-wrap
5999 msgid "B<packet>(7)\n"
6000 msgstr ""
6001
6002 #. type: Plain text
6003 #: build/C/man2/socket.2:126
6004 msgid ""
6005 "The socket has the indicated I<type>, which specifies the communication "
6006 "semantics.  Currently defined types are:"
6007 msgstr ""
6008
6009 #. type: TP
6010 #: build/C/man2/socket.2:126
6011 #, no-wrap
6012 msgid "B<SOCK_STREAM>"
6013 msgstr ""
6014
6015 #. type: Plain text
6016 #: build/C/man2/socket.2:130
6017 msgid ""
6018 "Provides sequenced, reliable, two-way, connection-based byte streams.  An "
6019 "out-of-band data transmission mechanism may be supported."
6020 msgstr ""
6021
6022 #. type: TP
6023 #: build/C/man2/socket.2:130
6024 #, no-wrap
6025 msgid "B<SOCK_DGRAM>"
6026 msgstr ""
6027
6028 #. type: Plain text
6029 #: build/C/man2/socket.2:134
6030 msgid ""
6031 "Supports datagrams (connectionless, unreliable messages of a fixed maximum "
6032 "length)."
6033 msgstr ""
6034
6035 #. type: TP
6036 #: build/C/man2/socket.2:134
6037 #, no-wrap
6038 msgid "B<SOCK_SEQPACKET>"
6039 msgstr ""
6040
6041 #. type: Plain text
6042 #: build/C/man2/socket.2:139
6043 msgid ""
6044 "Provides a sequenced, reliable, two-way connection-based data transmission "
6045 "path for datagrams of fixed maximum length; a consumer is required to read "
6046 "an entire packet with each input system call."
6047 msgstr ""
6048
6049 #. type: TP
6050 #: build/C/man2/socket.2:139
6051 #, no-wrap
6052 msgid "B<SOCK_RAW>"
6053 msgstr ""
6054
6055 #. type: Plain text
6056 #: build/C/man2/socket.2:142
6057 msgid "Provides raw network protocol access."
6058 msgstr ""
6059
6060 #. type: TP
6061 #: build/C/man2/socket.2:142
6062 #, no-wrap
6063 msgid "B<SOCK_RDM>"
6064 msgstr ""
6065
6066 #. type: Plain text
6067 #: build/C/man2/socket.2:145
6068 msgid "Provides a reliable datagram layer that does not guarantee ordering."
6069 msgstr ""
6070
6071 #. type: TP
6072 #: build/C/man2/socket.2:145
6073 #, no-wrap
6074 msgid "B<SOCK_PACKET>"
6075 msgstr ""
6076
6077 #. type: Plain text
6078 #: build/C/man2/socket.2:150
6079 msgid "Obsolete and should not be used in new programs; see B<packet>(7)."
6080 msgstr ""
6081
6082 #. type: Plain text
6083 #: build/C/man2/socket.2:156
6084 msgid ""
6085 "Some socket types may not be implemented by all protocol families; for "
6086 "example, B<SOCK_SEQPACKET> is not implemented for B<AF_INET>."
6087 msgstr ""
6088
6089 #. type: Plain text
6090 #: build/C/man2/socket.2:164
6091 msgid ""
6092 "Since Linux 2.6.27, the I<type> argument serves a second purpose: in "
6093 "addition to specifying a socket type, it may include the bitwise OR of any "
6094 "of the following values, to modify the behavior of B<socket>():"
6095 msgstr ""
6096
6097 #. type: Plain text
6098 #: build/C/man2/socket.2:198
6099 msgid ""
6100 "The I<protocol> specifies a particular protocol to be used with the socket.  "
6101 "Normally only a single protocol exists to support a particular socket type "
6102 "within a given protocol family, in which case I<protocol> can be specified "
6103 "as 0.  However, it is possible that many protocols may exist, in which case "
6104 "a particular protocol must be specified in this manner.  The protocol number "
6105 "to use is specific to the ``communication domain'' in which communication is "
6106 "to take place; see B<protocols>(5).  See B<getprotoent>(3)  on how to map "
6107 "protocol name strings to protocol numbers."
6108 msgstr ""
6109
6110 #. type: Plain text
6111 #: build/C/man2/socket.2:228
6112 msgid ""
6113 "Sockets of type B<SOCK_STREAM> are full-duplex byte streams, similar to "
6114 "pipes.  They do not preserve record boundaries.  A stream socket must be in "
6115 "a I<connected> state before any data may be sent or received on it.  A "
6116 "connection to another socket is created with a B<connect>(2)  call.  Once "
6117 "connected, data may be transferred using B<read>(2)  and B<write>(2)  calls "
6118 "or some variant of the B<send>(2)  and B<recv>(2)  calls.  When a session "
6119 "has been completed a B<close>(2)  may be performed.  Out-of-band data may "
6120 "also be transmitted as described in B<send>(2)  and received as described in "
6121 "B<recv>(2)."
6122 msgstr ""
6123
6124 #. type: Plain text
6125 #: build/C/man2/socket.2:254
6126 msgid ""
6127 "The communications protocols which implement a B<SOCK_STREAM> ensure that "
6128 "data is not lost or duplicated.  If a piece of data for which the peer "
6129 "protocol has buffer space cannot be successfully transmitted within a "
6130 "reasonable length of time, then the connection is considered to be dead.  "
6131 "When B<SO_KEEPALIVE> is enabled on the socket the protocol checks in a "
6132 "protocol-specific manner if the other end is still alive.  A B<SIGPIPE> "
6133 "signal is raised if a process sends or receives on a broken stream; this "
6134 "causes naive processes, which do not handle the signal, to exit.  "
6135 "B<SOCK_SEQPACKET> sockets employ the same system calls as B<SOCK_STREAM> "
6136 "sockets.  The only difference is that B<read>(2)  calls will return only the "
6137 "amount of data requested, and any data remaining in the arriving packet will "
6138 "be discarded.  Also all message boundaries in incoming datagrams are "
6139 "preserved."
6140 msgstr ""
6141
6142 #. type: Plain text
6143 #: build/C/man2/socket.2:264
6144 msgid ""
6145 "B<SOCK_DGRAM> and B<SOCK_RAW> sockets allow sending of datagrams to "
6146 "correspondents named in B<sendto>(2)  calls.  Datagrams are generally "
6147 "received with B<recvfrom>(2), which returns the next datagram along with the "
6148 "address of its sender."
6149 msgstr ""
6150
6151 #. type: Plain text
6152 #: build/C/man2/socket.2:271
6153 msgid ""
6154 "B<SOCK_PACKET> is an obsolete socket type to receive raw packets directly "
6155 "from the device driver.  Use B<packet>(7)  instead."
6156 msgstr ""
6157
6158 #. type: Plain text
6159 #: build/C/man2/socket.2:294
6160 msgid ""
6161 "An B<fcntl>(2)  B<F_SETOWN> operation can be used to specify a process or "
6162 "process group to receive a B<SIGURG> signal when the out-of-band data "
6163 "arrives or B<SIGPIPE> signal when a B<SOCK_STREAM> connection breaks "
6164 "unexpectedly.  This operation may also be used to set the process or process "
6165 "group that receives the I/O and asynchronous notification of I/O events via "
6166 "B<SIGIO>.  Using B<F_SETOWN> is equivalent to an B<ioctl>(2)  call with the "
6167 "B<FIOSETOWN> or B<SIOCSPGRP> argument."
6168 msgstr ""
6169
6170 #. type: Plain text
6171 #: build/C/man2/socket.2:304
6172 msgid ""
6173 "When the network signals an error condition to the protocol module (e.g., "
6174 "using a ICMP message for IP) the pending error flag is set for the socket.  "
6175 "The next operation on this socket will return the error code of the pending "
6176 "error.  For some protocols it is possible to enable a per-socket error queue "
6177 "to retrieve detailed information about the error; see B<IP_RECVERR> in "
6178 "B<ip>(7)."
6179 msgstr ""
6180
6181 #. type: Plain text
6182 #: build/C/man2/socket.2:314
6183 msgid ""
6184 "The operation of sockets is controlled by socket level I<options>.  These "
6185 "options are defined in I<E<lt>sys/socket.hE<gt>>.  The functions "
6186 "B<setsockopt>(2)  and B<getsockopt>(2)  are used to set and get options, "
6187 "respectively."
6188 msgstr ""
6189
6190 #. type: Plain text
6191 #: build/C/man2/socket.2:319
6192 msgid ""
6193 "On success, a file descriptor for the new socket is returned.  On error, -1 "
6194 "is returned, and I<errno> is set appropriately."
6195 msgstr ""
6196
6197 #. type: Plain text
6198 #: build/C/man2/socket.2:324
6199 msgid ""
6200 "Permission to create a socket of the specified type and/or protocol is "
6201 "denied."
6202 msgstr ""
6203
6204 #. type: Plain text
6205 #: build/C/man2/socket.2:327
6206 msgid "The implementation does not support the specified address family."
6207 msgstr ""
6208
6209 #. type: Plain text
6210 #: build/C/man2/socket.2:330
6211 msgid "Unknown protocol, or protocol family not available."
6212 msgstr ""
6213
6214 #.  Since Linux 2.6.27
6215 #. type: Plain text
6216 #: build/C/man2/socket.2:335
6217 msgid "Invalid flags in I<type>."
6218 msgstr ""
6219
6220 #. type: Plain text
6221 #: build/C/man2/socket.2:338
6222 msgid "Process file table overflow."
6223 msgstr ""
6224
6225 #. type: TP
6226 #: build/C/man2/socket.2:341
6227 #, no-wrap
6228 msgid "B<ENOBUFS> or B<ENOMEM>"
6229 msgstr ""
6230
6231 #. type: Plain text
6232 #: build/C/man2/socket.2:346
6233 msgid ""
6234 "Insufficient memory is available.  The socket cannot be created until "
6235 "sufficient resources are freed."
6236 msgstr ""
6237
6238 #. type: TP
6239 #: build/C/man2/socket.2:346 build/C/man2/socketpair.2:92
6240 #, no-wrap
6241 msgid "B<EPROTONOSUPPORT>"
6242 msgstr ""
6243
6244 #. type: Plain text
6245 #: build/C/man2/socket.2:350
6246 msgid ""
6247 "The protocol type or the specified protocol is not supported within this "
6248 "domain."
6249 msgstr ""
6250
6251 #. type: Plain text
6252 #: build/C/man2/socket.2:352
6253 msgid "Other errors may be generated by the underlying protocol modules."
6254 msgstr ""
6255
6256 #. type: Plain text
6257 #: build/C/man2/socket.2:354
6258 msgid "4.4BSD, POSIX.1-2001."
6259 msgstr ""
6260
6261 #. type: Plain text
6262 #: build/C/man2/socket.2:360
6263 msgid "The B<SOCK_NONBLOCK> and B<SOCK_CLOEXEC> flags are Linux-specific."
6264 msgstr ""
6265
6266 #. type: Plain text
6267 #: build/C/man2/socket.2:366
6268 msgid ""
6269 "B<socket>()  appeared in 4.2BSD.  It is generally portable to/from non-BSD "
6270 "systems supporting clones of the BSD socket layer (including System V "
6271 "variants)."
6272 msgstr ""
6273
6274 #. type: Plain text
6275 #: build/C/man2/socket.2:385
6276 msgid ""
6277 "The manifest constants used under 4.x BSD for protocol families are "
6278 "B<PF_UNIX>, B<PF_INET>, and so on, while B<AF_UNIX>, B<AF_INET>, and so on "
6279 "are used for address families.  However, already the BSD man page promises: "
6280 "\"The protocol family generally is the same as the address family\", and "
6281 "subsequent standards use AF_* everywhere."
6282 msgstr ""
6283
6284 #. type: Plain text
6285 #: build/C/man2/socket.2:390
6286 msgid "An example of the use of B<socket>()  is shown in B<getaddrinfo>(3)."
6287 msgstr ""
6288
6289 #. type: Plain text
6290 #: build/C/man2/socket.2:413
6291 msgid ""
6292 "B<accept>(2), B<bind>(2), B<connect>(2), B<fcntl>(2), B<getpeername>(2), "
6293 "B<getsockname>(2), B<getsockopt>(2), B<ioctl>(2), B<listen>(2), B<read>(2), "
6294 "B<recv>(2), B<select>(2), B<send>(2), B<shutdown>(2), B<socketpair>(2), "
6295 "B<write>(2), B<getprotoent>(3), B<ip>(7), B<socket>(7), B<tcp>(7), "
6296 "B<udp>(7), B<unix>(7)"
6297 msgstr ""
6298
6299 #. type: Plain text
6300 #: build/C/man2/socket.2:419
6301 msgid ""
6302 "\\(lqAn Introductory 4.3BSD Interprocess Communication Tutorial\\(rq and "
6303 "\\(lqBSD Interprocess Communication Tutorial\\(rq, reprinted in I<UNIX "
6304 "Programmer's Supplementary Documents Volume 1.>"
6305 msgstr ""
6306
6307 #. type: TH
6308 #: build/C/man7/socket.7:48
6309 #, no-wrap
6310 msgid "2013-03-15"
6311 msgstr ""
6312
6313 #. type: Plain text
6314 #: build/C/man7/socket.7:51
6315 msgid "socket - Linux socket interface"
6316 msgstr ""
6317
6318 #. type: Plain text
6319 #: build/C/man7/socket.7:55
6320 msgid ""
6321 "I<sockfd>B< = socket(int >I<socket_family>B<, int >I<socket_type>B<, int "
6322 ">I<protocol>B<);>"
6323 msgstr ""
6324
6325 #. type: Plain text
6326 #: build/C/man7/socket.7:74
6327 msgid ""
6328 "This manual page describes the Linux networking socket layer user "
6329 "interface.  The BSD compatible sockets are the uniform interface between the "
6330 "user process and the network protocol stacks in the kernel.  The protocol "
6331 "modules are grouped into I<protocol families> like B<AF_INET>, B<AF_IPX>, "
6332 "B<AF_PACKET> and I<socket types> like B<SOCK_STREAM> or B<SOCK_DGRAM>.  See "
6333 "B<socket>(2)  for more information on families and types."
6334 msgstr ""
6335
6336 #. type: SS
6337 #: build/C/man7/socket.7:74
6338 #, no-wrap
6339 msgid "Socket-layer functions"
6340 msgstr ""
6341
6342 #. type: Plain text
6343 #: build/C/man7/socket.7:78
6344 msgid ""
6345 "These functions are used by the user process to send or receive packets and "
6346 "to do other socket operations.  For more information see their respective "
6347 "manual pages."
6348 msgstr ""
6349
6350 #. type: Plain text
6351 #: build/C/man7/socket.7:94
6352 msgid ""
6353 "B<socket>(2)  creates a socket, B<connect>(2)  connects a socket to a remote "
6354 "socket address, the B<bind>(2)  function binds a socket to a local socket "
6355 "address, B<listen>(2)  tells the socket that new connections shall be "
6356 "accepted, and B<accept>(2)  is used to get a new socket with a new incoming "
6357 "connection.  B<socketpair>(2)  returns two connected anonymous sockets (only "
6358 "implemented for a few local families like B<AF_UNIX>)"
6359 msgstr ""
6360
6361 #. type: Plain text
6362 #: build/C/man7/socket.7:116
6363 msgid ""
6364 "B<send>(2), B<sendto>(2), and B<sendmsg>(2)  send data over a socket, and "
6365 "B<recv>(2), B<recvfrom>(2), B<recvmsg>(2)  receive data from a socket.  "
6366 "B<poll>(2)  and B<select>(2)  wait for arriving data or a readiness to send "
6367 "data.  In addition, the standard I/O operations like B<write>(2), "
6368 "B<writev>(2), B<sendfile>(2), B<read>(2), and B<readv>(2)  can be used to "
6369 "read and write data."
6370 msgstr ""
6371
6372 #. type: Plain text
6373 #: build/C/man7/socket.7:127
6374 msgid ""
6375 "B<getsockname>(2)  returns the local socket address and B<getpeername>(2)  "
6376 "returns the remote socket address.  B<getsockopt>(2)  and B<setsockopt>(2)  "
6377 "are used to set or get socket layer or protocol options.  B<ioctl>(2)  can "
6378 "be used to set or read some other options."
6379 msgstr ""
6380
6381 #. type: Plain text
6382 #: build/C/man7/socket.7:132
6383 msgid ""
6384 "B<close>(2)  is used to close a socket.  B<shutdown>(2)  closes parts of a "
6385 "full-duplex socket connection."
6386 msgstr ""
6387
6388 #. type: Plain text
6389 #: build/C/man7/socket.7:138
6390 msgid ""
6391 "Seeking, or calling B<pread>(2)  or B<pwrite>(2)  with a nonzero position is "
6392 "not supported on sockets."
6393 msgstr ""
6394
6395 #. type: Plain text
6396 #: build/C/man7/socket.7:155
6397 msgid ""
6398 "It is possible to do nonblocking I/O on sockets by setting the B<O_NONBLOCK> "
6399 "flag on a socket file descriptor using B<fcntl>(2).  Then all operations "
6400 "that would block will (usually)  return with B<EAGAIN> (operation should be "
6401 "retried later); B<connect>(2)  will return B<EINPROGRESS> error.  The user "
6402 "can then wait for various events via B<poll>(2)  or B<select>(2)."
6403 msgstr ""
6404
6405 #. type: tbl table
6406 #: build/C/man7/socket.7:159
6407 #, no-wrap
6408 msgid "I/O events\n"
6409 msgstr ""
6410
6411 #. type: tbl table
6412 #: build/C/man7/socket.7:160
6413 #, no-wrap
6414 msgid "Event:Poll flag:Occurrence\n"
6415 msgstr ""
6416
6417 #. type: tbl table
6418 #: build/C/man7/socket.7:161 build/C/man7/socket.7:164
6419 #, no-wrap
6420 msgid "Read:POLLIN:T{\n"
6421 msgstr ""
6422
6423 #. type: tbl table
6424 #: build/C/man7/socket.7:162
6425 #, no-wrap
6426 msgid "New data arrived.\n"
6427 msgstr ""
6428
6429 #. type: tbl table
6430 #: build/C/man7/socket.7:165
6431 #, no-wrap
6432 msgid "A connection setup has been completed\n"
6433 msgstr ""
6434
6435 #. type: tbl table
6436 #: build/C/man7/socket.7:166
6437 #, no-wrap
6438 msgid "(for connection-oriented sockets)\n"
6439 msgstr ""
6440
6441 #. type: tbl table
6442 #: build/C/man7/socket.7:168 build/C/man7/socket.7:171
6443 #, no-wrap
6444 msgid "Read:POLLHUP:T{\n"
6445 msgstr ""
6446
6447 #. type: tbl table
6448 #: build/C/man7/socket.7:169
6449 #, no-wrap
6450 msgid "A disconnection request has been initiated by the other end.\n"
6451 msgstr ""
6452
6453 #. type: tbl table
6454 #: build/C/man7/socket.7:172
6455 #, no-wrap
6456 msgid "A connection is broken (only for connection-oriented protocols).\n"
6457 msgstr ""
6458
6459 #. type: tbl table
6460 #: build/C/man7/socket.7:173
6461 #, no-wrap
6462 msgid "When the socket is written\n"
6463 msgstr ""
6464
6465 #. type: tbl table
6466 #: build/C/man7/socket.7:174
6467 #, no-wrap
6468 msgid "B<SIGPIPE>\n"
6469 msgstr ""
6470
6471 #. type: tbl table
6472 #: build/C/man7/socket.7:175
6473 #, no-wrap
6474 msgid "is also sent.\n"
6475 msgstr ""
6476
6477 #. type: tbl table
6478 #: build/C/man7/socket.7:177
6479 #, no-wrap
6480 msgid "Write:POLLOUT:T{\n"
6481 msgstr ""
6482
6483 #. type: tbl table
6484 #: build/C/man7/socket.7:178
6485 #, no-wrap
6486 msgid "Socket has enough send buffer space for writing new data.\n"
6487 msgstr ""
6488
6489 #. type: tbl table
6490 #: build/C/man7/socket.7:180
6491 #, no-wrap
6492 msgid "Read/Write:T{\n"
6493 msgstr ""
6494
6495 #. type: tbl table
6496 #: build/C/man7/socket.7:181
6497 #, no-wrap
6498 msgid "POLLIN|\n"
6499 msgstr ""
6500
6501 #. type: tbl table
6502 #: build/C/man7/socket.7:182
6503 #, no-wrap
6504 msgid ".br\n"
6505 msgstr ""
6506
6507 #. type: tbl table
6508 #: build/C/man7/socket.7:183
6509 #, no-wrap
6510 msgid "POLLOUT\n"
6511 msgstr ""
6512
6513 #. type: tbl table
6514 #: build/C/man7/socket.7:185
6515 #, no-wrap
6516 msgid "An outgoing\n"
6517 msgstr ""
6518
6519 #. type: tbl table
6520 #: build/C/man7/socket.7:186
6521 #, no-wrap
6522 msgid "B<connect>(2)\n"
6523 msgstr ""
6524
6525 #. type: tbl table
6526 #: build/C/man7/socket.7:187
6527 #, no-wrap
6528 msgid "finished.\n"
6529 msgstr ""
6530
6531 #. type: tbl table
6532 #: build/C/man7/socket.7:189
6533 #, no-wrap
6534 msgid "Read/Write:POLLERR:An asynchronous error occurred.\n"
6535 msgstr ""
6536
6537 #. type: tbl table
6538 #: build/C/man7/socket.7:190
6539 #, no-wrap
6540 msgid "Read/Write:POLLHUP:The other end has shut down one direction.\n"
6541 msgstr ""
6542
6543 #. type: tbl table
6544 #: build/C/man7/socket.7:191
6545 #, no-wrap
6546 msgid "Exception:POLLPRI:T{\n"
6547 msgstr ""
6548
6549 #. type: tbl table
6550 #: build/C/man7/socket.7:192
6551 #, no-wrap
6552 msgid "Urgent data arrived.\n"
6553 msgstr ""
6554
6555 #. type: tbl table
6556 #: build/C/man7/socket.7:193
6557 #, no-wrap
6558 msgid "B<SIGURG>\n"
6559 msgstr ""
6560
6561 #. type: tbl table
6562 #: build/C/man7/socket.7:194
6563 #, no-wrap
6564 msgid "is sent then.\n"
6565 msgstr ""
6566
6567 #. type: Plain text
6568 #: build/C/man7/socket.7:223
6569 msgid ""
6570 "An alternative to B<poll>(2)  and B<select>(2)  is to let the kernel inform "
6571 "the application about events via a B<SIGIO> signal.  For that the B<O_ASYNC> "
6572 "flag must be set on a socket file descriptor via B<fcntl>(2)  and a valid "
6573 "signal handler for B<SIGIO> must be installed via B<sigaction>(2).  See the "
6574 "I<Signals> discussion below."
6575 msgstr ""
6576
6577 #. type: SS
6578 #: build/C/man7/socket.7:223
6579 #, no-wrap
6580 msgid "Socket address structures"
6581 msgstr ""
6582
6583 #. type: Plain text
6584 #: build/C/man7/socket.7:239
6585 msgid ""
6586 "Each socket domain has its own format for socket addresses, with a "
6587 "domain-specific address structure.  Each of these structures begins with an "
6588 "integer \"family\" field (typed as I<sa_family_t>)  that indicates the type "
6589 "of the address structure.  This allows the various system calls (e.g., "
6590 "B<connect>(2), B<bind>(2), B<accept>(2), B<getsockname>(2), "
6591 "B<getpeername>(2)), which are generic to all socket domains, to determine "
6592 "the domain of a particular socket address."
6593 msgstr ""
6594
6595 #. type: Plain text
6596 #: build/C/man7/socket.7:249
6597 msgid ""
6598 "To allow any type of socket address to be passed to interfaces in the "
6599 "sockets API, the type I<struct sockaddr> is defined.  The purpose of this "
6600 "type is purely to allow casting of domain-specific socket address types to a "
6601 "\"generic\" type, so as to avoid compiler warnings about type mismatches in "
6602 "calls to the sockets API."
6603 msgstr ""
6604
6605 #. type: Plain text
6606 #: build/C/man7/socket.7:259
6607 msgid ""
6608 "In addition, the sockets API provides the data type I<struct "
6609 "sockaddr_storage>.  This type is suitable to accommodate all supported "
6610 "domain-specific socket address structures; it is large enough and is aligned "
6611 "properly.  (In particular, it is large enough to hold IPv6 socket "
6612 "addresses.)  The structure includes the following field, which can be used "
6613 "to identify the type of socket address actually stored in the structure:"
6614 msgstr ""
6615
6616 #. type: Plain text
6617 #: build/C/man7/socket.7:263
6618 #, no-wrap
6619 msgid "    sa_family_t ss_family;\n"
6620 msgstr ""
6621
6622 #. type: Plain text
6623 #: build/C/man7/socket.7:271
6624 msgid ""
6625 "The I<sockaddr_storage> structure is useful in programs that must handle "
6626 "socket addresses in a generic way (e.g., programs that must deal with both "
6627 "IPv4 and IPv6 socket addresses)."
6628 msgstr ""
6629
6630 #. type: SS
6631 #: build/C/man7/socket.7:271
6632 #, no-wrap
6633 msgid "Socket options"
6634 msgstr ""
6635
6636 #.  FIXME
6637 #.  In the list below, the text used to describe argument types
6638 #.  for each socket option should be more consistent
6639 #
6640 #.  SO_ACCEPTCONN is in POSIX.1-2001, and its origin is explained in
6641 #.  W R Stevens, UNPv1
6642 #. type: Plain text
6643 #: build/C/man7/socket.7:285
6644 msgid ""
6645 "These socket options can be set by using B<setsockopt>(2)  and read with "
6646 "B<getsockopt>(2)  with the socket level set to B<SOL_SOCKET> for all "
6647 "sockets:"
6648 msgstr ""
6649
6650 #. type: TP
6651 #: build/C/man7/socket.7:285
6652 #, no-wrap
6653 msgid "B<SO_ACCEPTCONN>"
6654 msgstr ""
6655
6656 #. type: Plain text
6657 #: build/C/man7/socket.7:293
6658 msgid ""
6659 "Returns a value indicating whether or not this socket has been marked to "
6660 "accept connections with B<listen>(2).  The value 0 indicates that this is "
6661 "not a listening socket, the value 1 indicates that this is a listening "
6662 "socket.  This socket option is read-only."
6663 msgstr ""
6664
6665 #. type: TP
6666 #: build/C/man7/socket.7:293
6667 #, no-wrap
6668 msgid "B<SO_BINDTODEVICE>"
6669 msgstr ""
6670
6671 #. type: Plain text
6672 #: build/C/man7/socket.7:312
6673 msgid ""
6674 "Bind this socket to a particular device like \\(lqeth0\\(rq, as specified in "
6675 "the passed interface name.  If the name is an empty string or the option "
6676 "length is zero, the socket device binding is removed.  The passed option is "
6677 "a variable-length null-terminated interface name string with the maximum "
6678 "size of B<IFNAMSIZ>.  If a socket is bound to an interface, only packets "
6679 "received from that particular interface are processed by the socket.  Note "
6680 "that this only works for some socket types, particularly B<AF_INET> "
6681 "sockets.  It is not supported for packet sockets (use normal B<bind>(2)  "
6682 "there)."
6683 msgstr ""
6684
6685 #. type: Plain text
6686 #: build/C/man7/socket.7:326
6687 msgid ""
6688 "Before Linux 3.8, this socket option could be set, but could not retrieved "
6689 "with B<getsockopt>(2).  Since Linux 3.8, it is readable.  The I<optlen> "
6690 "argument should contain the buffer size available to receive the device name "
6691 "and is recommended to be B<IFNAMSZ> bytes.  The real device name length is "
6692 "reported back in the I<optlen> argument."
6693 msgstr ""
6694
6695 #. type: TP
6696 #: build/C/man7/socket.7:326
6697 #, no-wrap
6698 msgid "B<SO_BROADCAST>"
6699 msgstr ""
6700
6701 #. type: Plain text
6702 #: build/C/man7/socket.7:332
6703 msgid ""
6704 "Set or get the broadcast flag.  When enabled, datagram sockets are allowed "
6705 "to send packets to a broadcast address.  This option has no effect on "
6706 "stream-oriented sockets."
6707 msgstr ""
6708
6709 #. type: TP
6710 #: build/C/man7/socket.7:332
6711 #, no-wrap
6712 msgid "B<SO_BSDCOMPAT>"
6713 msgstr ""
6714
6715 #. type: Plain text
6716 #: build/C/man7/socket.7:344
6717 msgid ""
6718 "Enable BSD bug-to-bug compatibility.  This is used by the UDP protocol "
6719 "module in Linux 2.0 and 2.2.  If enabled ICMP errors received for a UDP "
6720 "socket will not be passed to the user program.  In later kernel versions, "
6721 "support for this option has been phased out: Linux 2.4 silently ignores it, "
6722 "and Linux 2.6 generates a kernel warning (printk()) if a program uses this "
6723 "option.  Linux 2.0 also enabled BSD bug-to-bug compatibility options (random "
6724 "header changing, skipping of the broadcast flag) for raw sockets with this "
6725 "option, but that was removed in Linux 2.2."
6726 msgstr ""
6727
6728 #. type: TP
6729 #: build/C/man7/socket.7:344
6730 #, no-wrap
6731 msgid "B<SO_DEBUG>"
6732 msgstr ""
6733
6734 #. type: Plain text
6735 #: build/C/man7/socket.7:350
6736 msgid ""
6737 "Enable socket debugging.  Only allowed for processes with the "
6738 "B<CAP_NET_ADMIN> capability or an effective user ID of 0."
6739 msgstr ""
6740
6741 #. type: TP
6742 #: build/C/man7/socket.7:350
6743 #, no-wrap
6744 msgid "B<SO_DOMAIN> (since Linux 2.6.32)"
6745 msgstr ""
6746
6747 #. type: Plain text
6748 #: build/C/man7/socket.7:358
6749 msgid ""
6750 "Retrieves the socket domain as an integer, returning a value such as "
6751 "B<AF_INET6>.  See B<socket>(2)  for details.  This socket option is "
6752 "read-only."
6753 msgstr ""
6754
6755 #. type: TP
6756 #: build/C/man7/socket.7:358
6757 #, no-wrap
6758 msgid "B<SO_ERROR>"
6759 msgstr ""
6760
6761 #. type: Plain text
6762 #: build/C/man7/socket.7:363
6763 msgid ""
6764 "Get and clear the pending socket error.  This socket option is read-only.  "
6765 "Expects an integer."
6766 msgstr ""
6767
6768 #. type: TP
6769 #: build/C/man7/socket.7:363
6770 #, no-wrap
6771 msgid "B<SO_DONTROUTE>"
6772 msgstr ""
6773
6774 #. type: Plain text
6775 #: build/C/man7/socket.7:372
6776 msgid ""
6777 "Don't send via a gateway, only send to directly connected hosts.  The same "
6778 "effect can be achieved by setting the B<MSG_DONTROUTE> flag on a socket "
6779 "B<send>(2)  operation.  Expects an integer boolean flag."
6780 msgstr ""
6781
6782 #. type: TP
6783 #: build/C/man7/socket.7:372
6784 #, no-wrap
6785 msgid "B<SO_KEEPALIVE>"
6786 msgstr ""
6787
6788 #. type: Plain text
6789 #: build/C/man7/socket.7:376
6790 msgid ""
6791 "Enable sending of keep-alive messages on connection-oriented sockets.  "
6792 "Expects an integer boolean flag."
6793 msgstr ""
6794
6795 #. type: TP
6796 #: build/C/man7/socket.7:376
6797 #, no-wrap
6798 msgid "B<SO_LINGER>"
6799 msgstr ""
6800
6801 #. type: Plain text
6802 #: build/C/man7/socket.7:384
6803 msgid ""
6804 "Sets or gets the B<SO_LINGER> option.  The argument is a I<linger> "
6805 "structure."
6806 msgstr ""
6807
6808 #. type: Plain text
6809 #: build/C/man7/socket.7:391
6810 #, no-wrap
6811 msgid ""
6812 "struct linger {\n"
6813 "    int l_onoff;    /* linger active */\n"
6814 "    int l_linger;   /* how many seconds to linger for */\n"
6815 "};\n"
6816 msgstr ""
6817
6818 #. type: Plain text
6819 #: build/C/man7/socket.7:405
6820 msgid ""
6821 "When enabled, a B<close>(2)  or B<shutdown>(2)  will not return until all "
6822 "queued messages for the socket have been successfully sent or the linger "
6823 "timeout has been reached.  Otherwise, the call returns immediately and the "
6824 "closing is done in the background.  When the socket is closed as part of "
6825 "B<exit>(2), it always lingers in the background."
6826 msgstr ""
6827
6828 #. type: TP
6829 #: build/C/man7/socket.7:405
6830 #, no-wrap
6831 msgid "B<SO_MARK> (since Linux 2.6.25)"
6832 msgstr ""
6833
6834 #.  commit 4a19ec5800fc3bb64e2d87c4d9fdd9e636086fe0
6835 #.  and    914a9ab386a288d0f22252fc268ecbc048cdcbd5
6836 #. type: Plain text
6837 #: build/C/man7/socket.7:416
6838 msgid ""
6839 "Set the mark for each packet sent through this socket (similar to the "
6840 "netfilter MARK target but socket-based).  Changing the mark can be used for "
6841 "mark-based routing without netfilter or for packet filtering.  Setting this "
6842 "option requires the B<CAP_NET_ADMIN> capability."
6843 msgstr ""
6844
6845 #. type: TP
6846 #: build/C/man7/socket.7:416
6847 #, no-wrap
6848 msgid "B<SO_OOBINLINE>"
6849 msgstr ""
6850
6851 #.  don't document it because it can do too much harm.
6852 #. .B SO_NO_CHECK
6853 #. type: Plain text
6854 #: build/C/man7/socket.7:425
6855 msgid ""
6856 "If this option is enabled, out-of-band data is directly placed into the "
6857 "receive data stream.  Otherwise out-of-band data is only passed when the "
6858 "B<MSG_OOB> flag is set during receiving."
6859 msgstr ""
6860
6861 #. type: TP
6862 #: build/C/man7/socket.7:425
6863 #, no-wrap
6864 msgid "B<SO_PASSCRED>"
6865 msgstr ""
6866
6867 #.  FIXME Document SO_PASSSEC, added in 2.6.18; there is some info
6868 #.  in the 2.6.18 ChangeLog
6869 #. type: Plain text
6870 #: build/C/man7/socket.7:434
6871 msgid ""
6872 "Enable or disable the receiving of the B<SCM_CREDENTIALS> control message.  "
6873 "For more information see B<unix>(7)."
6874 msgstr ""
6875
6876 #. type: TP
6877 #: build/C/man7/socket.7:434
6878 #, no-wrap
6879 msgid "B<SO_PEERCRED>"
6880 msgstr ""
6881
6882 #. type: Plain text
6883 #: build/C/man7/socket.7:457
6884 msgid ""
6885 "Return the credentials of the foreign process connected to this socket.  "
6886 "This is only possible for connected B<AF_UNIX> stream sockets and B<AF_UNIX> "
6887 "stream and datagram socket pairs created using B<socketpair>(2); see "
6888 "B<unix>(7).  The returned credentials are those that were in effect at the "
6889 "time of the call to B<connect>(2)  or B<socketpair>(2).  The argument is a "
6890 "I<ucred> structure; define the B<GNU_SOURCE> feature test macro to obtain "
6891 "the definition of that structure from I<E<lt>sys/socket.hE<gt>>.  This "
6892 "socket option is read-only."
6893 msgstr ""
6894
6895 #. type: TP
6896 #: build/C/man7/socket.7:457
6897 #, no-wrap
6898 msgid "B<SO_PRIORITY>"
6899 msgstr ""
6900
6901 #. type: Plain text
6902 #: build/C/man7/socket.7:470
6903 msgid ""
6904 "Set the protocol-defined priority for all packets to be sent on this "
6905 "socket.  Linux uses this value to order the networking queues: packets with "
6906 "a higher priority may be processed first depending on the selected device "
6907 "queueing discipline.  For B<ip>(7), this also sets the IP type-of-service "
6908 "(TOS) field for outgoing packets.  Setting a priority outside the range 0 to "
6909 "6 requires the B<CAP_NET_ADMIN> capability."
6910 msgstr ""
6911
6912 #. type: TP
6913 #: build/C/man7/socket.7:470
6914 #, no-wrap
6915 msgid "B<SO_PROTOCOL> (since Linux 2.6.32)"
6916 msgstr ""
6917
6918 #. type: Plain text
6919 #: build/C/man7/socket.7:478
6920 msgid ""
6921 "Retrieves the socket protocol as an integer, returning a value such as "
6922 "B<IPPROTO_SCTP>.  See B<socket>(2)  for details.  This socket option is "
6923 "read-only."
6924 msgstr ""
6925
6926 #. type: TP
6927 #: build/C/man7/socket.7:478
6928 #, no-wrap
6929 msgid "B<SO_RCVBUF>"
6930 msgstr ""
6931
6932 #.  Most (all?) other implementations do not do this -- MTK, Dec 05
6933 #.  The following thread on LMKL is quite informative:
6934 #.  getsockopt/setsockopt with SO_RCVBUF and SO_SNDBUF "non-standard" behaviour
6935 #.  17 July 2012
6936 #.  http://thread.gmane.org/gmane.linux.kernel/1328935
6937 #. type: Plain text
6938 #: build/C/man7/socket.7:497
6939 msgid ""
6940 "Sets or gets the maximum socket receive buffer in bytes.  The kernel doubles "
6941 "this value (to allow space for bookkeeping overhead)  when it is set using "
6942 "B<setsockopt>(2), and this doubled value is returned by B<getsockopt>(2).  "
6943 "The default value is set by the I</proc/sys/net/core/rmem_default> file, and "
6944 "the maximum allowed value is set by the I</proc/sys/net/core/rmem_max> "
6945 "file.  The minimum (doubled) value for this option is 256."
6946 msgstr ""
6947
6948 #. type: TP
6949 #: build/C/man7/socket.7:497
6950 #, no-wrap
6951 msgid "B<SO_RCVBUFFORCE> (since Linux 2.6.14)"
6952 msgstr ""
6953
6954 #. type: Plain text
6955 #: build/C/man7/socket.7:506
6956 msgid ""
6957 "Using this socket option, a privileged (B<CAP_NET_ADMIN>)  process can "
6958 "perform the same task as B<SO_RCVBUF>, but the I<rmem_max> limit can be "
6959 "overridden."
6960 msgstr ""
6961
6962 #. type: TP
6963 #: build/C/man7/socket.7:506
6964 #, no-wrap
6965 msgid "B<SO_RCVLOWAT> and B<SO_SNDLOWAT>"
6966 msgstr ""
6967
6968 #.  See http://marc.theaimsgroup.com/?l=linux-kernel&m=111049368106984&w=2
6969 #.  Tested on kernel 2.6.14 -- mtk, 30 Nov 05
6970 #. type: Plain text
6971 #: build/C/man7/socket.7:535
6972 msgid ""
6973 "Specify the minimum number of bytes in the buffer until the socket layer "
6974 "will pass the data to the protocol (B<SO_SNDLOWAT>)  or the user on "
6975 "receiving (B<SO_RCVLOWAT>).  These two values are initialized to 1.  "
6976 "B<SO_SNDLOWAT> is not changeable on Linux (B<setsockopt>(2)  fails with the "
6977 "error B<ENOPROTOOPT>).  B<SO_RCVLOWAT> is changeable only since Linux 2.4.  "
6978 "The B<select>(2)  and B<poll>(2)  system calls currently do not respect the "
6979 "B<SO_RCVLOWAT> setting on Linux, and mark a socket readable when even a "
6980 "single byte of data is available.  A subsequent read from the socket will "
6981 "block until B<SO_RCVLOWAT> bytes are available."
6982 msgstr ""
6983
6984 #. type: TP
6985 #: build/C/man7/socket.7:535
6986 #, no-wrap
6987 msgid "B<SO_RCVTIMEO> and B<SO_SNDTIMEO>"
6988 msgstr ""
6989
6990 #.  Not implemented in 2.0.
6991 #.  Implemented in 2.1.11 for getsockopt: always return a zero struct.
6992 #.  Implemented in 2.3.41 for setsockopt, and actually used.
6993 #.  in fact to EAGAIN
6994 #. type: Plain text
6995 #: build/C/man7/socket.7:570
6996 msgid ""
6997 "Specify the receiving or sending timeouts until reporting an error.  The "
6998 "argument is a I<struct timeval>.  If an input or output function blocks for "
6999 "this period of time, and data has been sent or received, the return value of "
7000 "that function will be the amount of data transferred; if no data has been "
7001 "transferred and the timeout has been reached then -1 is returned with "
7002 "I<errno> set to B<EAGAIN> or B<EWOULDBLOCK>, or B<EINPROGRESS> (for "
7003 "B<connect>(2))  just as if the socket was specified to be nonblocking.  If "
7004 "the timeout is set to zero (the default)  then the operation will never "
7005 "timeout.  Timeouts only have effect for system calls that perform socket I/O "
7006 "(e.g., B<read>(2), B<recvmsg>(2), B<send>(2), B<sendmsg>(2)); timeouts have "
7007 "no effect for B<select>(2), B<poll>(2), B<epoll_wait>(2), and so on."
7008 msgstr ""
7009
7010 #. type: TP
7011 #: build/C/man7/socket.7:570
7012 #, no-wrap
7013 msgid "B<SO_REUSEADDR>"
7014 msgstr ""
7015
7016 #. type: Plain text
7017 #: build/C/man7/socket.7:585
7018 msgid ""
7019 "Indicates that the rules used in validating addresses supplied in a "
7020 "B<bind>(2)  call should allow reuse of local addresses.  For B<AF_INET> "
7021 "sockets this means that a socket may bind, except when there is an active "
7022 "listening socket bound to the address.  When the listening socket is bound "
7023 "to B<INADDR_ANY> with a specific port then it is not possible to bind to "
7024 "this port for any local address.  Argument is an integer boolean flag."
7025 msgstr ""
7026
7027 #. type: TP
7028 #: build/C/man7/socket.7:585
7029 #, no-wrap
7030 msgid "B<SO_SNDBUF>"
7031 msgstr ""
7032
7033 #.  Most (all?) other implementations do not do this -- MTK, Dec 05
7034 #.  See also the comment to SO_RCVBUF (17 Jul 2012 LKML mail)
7035 #. type: Plain text
7036 #: build/C/man7/socket.7:601
7037 msgid ""
7038 "Sets or gets the maximum socket send buffer in bytes.  The kernel doubles "
7039 "this value (to allow space for bookkeeping overhead)  when it is set using "
7040 "B<setsockopt>(2), and this doubled value is returned by B<getsockopt>(2).  "
7041 "The default value is set by the I</proc/sys/net/core/wmem_default> file and "
7042 "the maximum allowed value is set by the I</proc/sys/net/core/wmem_max> "
7043 "file.  The minimum (doubled) value for this option is 2048."
7044 msgstr ""
7045
7046 #. type: TP
7047 #: build/C/man7/socket.7:601
7048 #, no-wrap
7049 msgid "B<SO_SNDBUFFORCE> (since Linux 2.6.14)"
7050 msgstr ""
7051
7052 #. type: Plain text
7053 #: build/C/man7/socket.7:610
7054 msgid ""
7055 "Using this socket option, a privileged (B<CAP_NET_ADMIN>)  process can "
7056 "perform the same task as B<SO_SNDBUF>, but the I<wmem_max> limit can be "
7057 "overridden."
7058 msgstr ""
7059
7060 #. type: TP
7061 #: build/C/man7/socket.7:610
7062 #, no-wrap
7063 msgid "B<SO_TIMESTAMP>"
7064 msgstr ""
7065
7066 #. type: Plain text
7067 #: build/C/man7/socket.7:626
7068 msgid ""
7069 "Enable or disable the receiving of the B<SO_TIMESTAMP> control message.  The "
7070 "timestamp control message is sent with level B<SOL_SOCKET> and the "
7071 "I<cmsg_data> field is a I<struct timeval> indicating the reception time of "
7072 "the last packet passed to the user in this call.  See B<cmsg>(3)  for "
7073 "details on control messages."
7074 msgstr ""
7075
7076 #. type: TP
7077 #: build/C/man7/socket.7:626
7078 #, no-wrap
7079 msgid "B<SO_TYPE>"
7080 msgstr ""
7081
7082 #. type: Plain text
7083 #: build/C/man7/socket.7:631
7084 msgid ""
7085 "Gets the socket type as an integer (e.g., B<SOCK_STREAM>).  This socket "
7086 "option is read-only."
7087 msgstr ""
7088
7089 #. type: SS
7090 #: build/C/man7/socket.7:631
7091 #, no-wrap
7092 msgid "Signals"
7093 msgstr ""
7094
7095 #. type: Plain text
7096 #: build/C/man7/socket.7:642
7097 msgid ""
7098 "When writing onto a connection-oriented socket that has been shut down (by "
7099 "the local or the remote end)  B<SIGPIPE> is sent to the writing process and "
7100 "B<EPIPE> is returned.  The signal is not sent when the write call specified "
7101 "the B<MSG_NOSIGNAL> flag."
7102 msgstr ""
7103
7104 #. type: Plain text
7105 #: build/C/man7/socket.7:667
7106 msgid ""
7107 "When requested with the B<FIOSETOWN> B<fcntl>(2)  or B<SIOCSPGRP> "
7108 "B<ioctl>(2), B<SIGIO> is sent when an I/O event occurs.  It is possible to "
7109 "use B<poll>(2)  or B<select>(2)  in the signal handler to find out which "
7110 "socket the event occurred on.  An alternative (in Linux 2.2) is to set a "
7111 "real-time signal using the B<F_SETSIG> B<fcntl>(2); the handler of the real "
7112 "time signal will be called with the file descriptor in the I<si_fd> field of "
7113 "its I<siginfo_t>.  See B<fcntl>(2)  for more information."
7114 msgstr ""
7115
7116 #.  .SS Ancillary messages
7117 #. type: Plain text
7118 #: build/C/man7/socket.7:675
7119 msgid ""
7120 "Under some circumstances (e.g., multiple processes accessing a single "
7121 "socket), the condition that caused the B<SIGIO> may have already disappeared "
7122 "when the process reacts to the signal.  If this happens, the process should "
7123 "wait again because Linux will resend the signal later."
7124 msgstr ""
7125
7126 #. type: SS
7127 #: build/C/man7/socket.7:675
7128 #, no-wrap
7129 msgid "/proc interfaces"
7130 msgstr ""
7131
7132 #. type: Plain text
7133 #: build/C/man7/socket.7:679
7134 msgid ""
7135 "The core socket networking parameters can be accessed via files in the "
7136 "directory I</proc/sys/net/core/>."
7137 msgstr ""
7138
7139 #. type: TP
7140 #: build/C/man7/socket.7:679
7141 #, no-wrap
7142 msgid "I<rmem_default>"
7143 msgstr ""
7144
7145 #. type: Plain text
7146 #: build/C/man7/socket.7:682
7147 msgid "contains the default setting in bytes of the socket receive buffer."
7148 msgstr ""
7149
7150 #. type: TP
7151 #: build/C/man7/socket.7:682
7152 #, no-wrap
7153 msgid "I<rmem_max>"
7154 msgstr ""
7155
7156 #. type: Plain text
7157 #: build/C/man7/socket.7:688
7158 msgid ""
7159 "contains the maximum socket receive buffer size in bytes which a user may "
7160 "set by using the B<SO_RCVBUF> socket option."
7161 msgstr ""
7162
7163 #. type: TP
7164 #: build/C/man7/socket.7:688
7165 #, no-wrap
7166 msgid "I<wmem_default>"
7167 msgstr ""
7168
7169 #. type: Plain text
7170 #: build/C/man7/socket.7:691
7171 msgid "contains the default setting in bytes of the socket send buffer."
7172 msgstr ""
7173
7174 #. type: TP
7175 #: build/C/man7/socket.7:691
7176 #, no-wrap
7177 msgid "I<wmem_max>"
7178 msgstr ""
7179
7180 #. type: Plain text
7181 #: build/C/man7/socket.7:697
7182 msgid ""
7183 "contains the maximum socket send buffer size in bytes which a user may set "
7184 "by using the B<SO_SNDBUF> socket option."
7185 msgstr ""
7186
7187 #. type: TP
7188 #: build/C/man7/socket.7:697
7189 #, no-wrap
7190 msgid "I<message_cost> and I<message_burst>"
7191 msgstr ""
7192
7193 #. type: Plain text
7194 #: build/C/man7/socket.7:701
7195 msgid ""
7196 "configure the token bucket filter used to load limit warning messages caused "
7197 "by external network events."
7198 msgstr ""
7199
7200 #. type: TP
7201 #: build/C/man7/socket.7:701
7202 #, no-wrap
7203 msgid "I<netdev_max_backlog>"
7204 msgstr ""
7205
7206 #. type: Plain text
7207 #: build/C/man7/socket.7:704
7208 msgid "Maximum number of packets in the global input queue."
7209 msgstr ""
7210
7211 #. type: TP
7212 #: build/C/man7/socket.7:704
7213 #, no-wrap
7214 msgid "I<optmem_max>"
7215 msgstr ""
7216
7217 #.  netdev_fastroute is not documented because it is experimental
7218 #. type: Plain text
7219 #: build/C/man7/socket.7:709
7220 msgid ""
7221 "Maximum length of ancillary data and user control data like the iovecs per "
7222 "socket."
7223 msgstr ""
7224
7225 #. type: SS
7226 #: build/C/man7/socket.7:709
7227 #, no-wrap
7228 msgid "Ioctls"
7229 msgstr ""
7230
7231 #. type: Plain text
7232 #: build/C/man7/socket.7:712
7233 msgid "These operations can be accessed using B<ioctl>(2):"
7234 msgstr ""
7235
7236 #. type: Plain text
7237 #: build/C/man7/socket.7:716
7238 #, no-wrap
7239 msgid ""
7240 "I<error>B< = ioctl(>I<ip_socket>B<, >I<ioctl_type>B<, "
7241 ">I<&value_result>B<);>\n"
7242 msgstr ""
7243
7244 #. type: TP
7245 #: build/C/man7/socket.7:718
7246 #, no-wrap
7247 msgid "B<SIOCGSTAMP>"
7248 msgstr ""
7249
7250 #. type: Plain text
7251 #: build/C/man7/socket.7:742
7252 msgid ""
7253 "Return a I<struct timeval> with the receive timestamp of the last packet "
7254 "passed to the user.  This is useful for accurate round trip time "
7255 "measurements.  See B<setitimer>(2)  for a description of I<struct timeval>.  "
7256 "This ioctl should only be used if the socket option B<SO_TIMESTAMP> is not "
7257 "set on the socket.  Otherwise, it returns the timestamp of the last packet "
7258 "that was received while B<SO_TIMESTAMP> was not set, or it fails if no such "
7259 "packet has been received, (i.e., B<ioctl>(2)  returns -1 with I<errno> set "
7260 "to B<ENOENT>)."
7261 msgstr ""
7262
7263 #. type: TP
7264 #: build/C/man7/socket.7:742
7265 #, no-wrap
7266 msgid "B<SIOCSPGRP>"
7267 msgstr ""
7268
7269 #. type: Plain text
7270 #: build/C/man7/socket.7:761
7271 msgid ""
7272 "Set the process or process group to send B<SIGIO> or B<SIGURG> signals to "
7273 "when an asynchronous I/O operation has finished or urgent data is "
7274 "available.  The argument is a pointer to a I<pid_t>.  If the argument is "
7275 "positive, send the signals to that process.  If the argument is negative, "
7276 "send the signals to the process group with the ID of the absolute value of "
7277 "the argument.  The process may only choose itself or its own process group "
7278 "to receive signals unless it has the B<CAP_KILL> capability or an effective "
7279 "UID of 0."
7280 msgstr ""
7281
7282 #. type: TP
7283 #: build/C/man7/socket.7:761
7284 #, no-wrap
7285 msgid "B<FIOASYNC>"
7286 msgstr ""
7287
7288 #. type: Plain text
7289 #: build/C/man7/socket.7:771
7290 msgid ""
7291 "Change the B<O_ASYNC> flag to enable or disable asynchronous I/O mode of the "
7292 "socket.  Asynchronous I/O mode means that the B<SIGIO> signal or the signal "
7293 "set with B<F_SETSIG> is raised when a new I/O event occurs."
7294 msgstr ""
7295
7296 #. type: Plain text
7297 #: build/C/man7/socket.7:779
7298 msgid ""
7299 "Argument is an integer boolean flag.  (This operation is synonymous with the "
7300 "use of B<fcntl>(2)  to set the B<O_ASYNC> flag.)"
7301 msgstr ""
7302
7303 #. type: TP
7304 #: build/C/man7/socket.7:779
7305 #, no-wrap
7306 msgid "B<SIOCGPGRP>"
7307 msgstr ""
7308
7309 #. type: Plain text
7310 #: build/C/man7/socket.7:788
7311 msgid ""
7312 "Get the current process or process group that receives B<SIGIO> or B<SIGURG> "
7313 "signals, or 0 when none is set."
7314 msgstr ""
7315
7316 #. type: Plain text
7317 #: build/C/man7/socket.7:792
7318 msgid "Valid B<fcntl>(2)  operations:"
7319 msgstr ""
7320
7321 #. type: TP
7322 #: build/C/man7/socket.7:792
7323 #, no-wrap
7324 msgid "B<FIOGETOWN>"
7325 msgstr ""
7326
7327 #. type: Plain text
7328 #: build/C/man7/socket.7:797
7329 msgid "The same as the B<SIOCGPGRP> B<ioctl>(2)."
7330 msgstr ""
7331
7332 #. type: TP
7333 #: build/C/man7/socket.7:797
7334 #, no-wrap
7335 msgid "B<FIOSETOWN>"
7336 msgstr ""
7337
7338 #. type: Plain text
7339 #: build/C/man7/socket.7:802
7340 msgid "The same as the B<SIOCSPGRP> B<ioctl>(2)."
7341 msgstr ""
7342
7343 #. type: Plain text
7344 #: build/C/man7/socket.7:816
7345 msgid ""
7346 "B<SO_BINDTODEVICE> was introduced in Linux 2.0.30.  B<SO_PASSCRED> is new in "
7347 "Linux 2.2.  The I</proc> interfaces was introduced in Linux 2.2.  "
7348 "B<SO_RCVTIMEO> and B<SO_SNDTIMEO> are supported since Linux 2.3.41.  "
7349 "Earlier, timeouts were fixed to a protocol-specific setting, and could not "
7350 "be read or written."
7351 msgstr ""
7352
7353 #. type: Plain text
7354 #: build/C/man7/socket.7:821
7355 msgid ""
7356 "Linux assumes that half of the send/receive buffer is used for internal "
7357 "kernel structures; thus the values in the corresponding I</proc> files are "
7358 "twice what can be observed on the wire."
7359 msgstr ""
7360
7361 #. type: Plain text
7362 #: build/C/man7/socket.7:834
7363 msgid ""
7364 "Linux will only allow port reuse with the B<SO_REUSEADDR> option when this "
7365 "option was set both in the previous program that performed a B<bind>(2)  to "
7366 "the port and in the program that wants to reuse the port.  This differs from "
7367 "some implementations (e.g., FreeBSD)  where only the later program needs to "
7368 "set the B<SO_REUSEADDR> option.  Typically this difference is invisible, "
7369 "since, for example, a server program is designed to always set this option."
7370 msgstr ""
7371
7372 #.  FIXME Document SO_ATTACH_FILTER and SO_DETACH_FILTER
7373 #.  .SH AUTHORS
7374 #.  This man page was written by Andi Kleen.
7375 #. type: Plain text
7376 #: build/C/man7/socket.7:847
7377 msgid ""
7378 "The B<CONFIG_FILTER> socket options B<SO_ATTACH_FILTER> and "
7379 "B<SO_DETACH_FILTER> are not documented.  The suggested interface to use them "
7380 "is via the libpcap library."
7381 msgstr ""
7382
7383 #. type: Plain text
7384 #: build/C/man7/socket.7:859
7385 msgid ""
7386 "B<getsockopt>(2), B<connect>(2), B<setsockopt>(2), B<socket>(2), "
7387 "B<capabilities>(7), B<ddp>(7), B<ip>(7), B<packet>(7), B<tcp>(7), B<udp>(7), "
7388 "B<unix>(7)"
7389 msgstr ""
7390
7391 #. type: TH
7392 #: build/C/man2/socketcall.2:25
7393 #, no-wrap
7394 msgid "SOCKETCALL"
7395 msgstr ""
7396
7397 #. type: TH
7398 #: build/C/man2/socketcall.2:25
7399 #, no-wrap
7400 msgid "2012-10-16"
7401 msgstr ""
7402
7403 #. type: Plain text
7404 #: build/C/man2/socketcall.2:28
7405 msgid "socketcall - socket system calls"
7406 msgstr ""
7407
7408 #. type: Plain text
7409 #: build/C/man2/socketcall.2:30
7410 msgid "B<int socketcall(int >I<call>B<, unsigned long *>I<args>B<);>"
7411 msgstr ""
7412
7413 #. type: Plain text
7414 #: build/C/man2/socketcall.2:38
7415 msgid ""
7416 "B<socketcall>()  is a common kernel entry point for the socket system "
7417 "calls.  I<call> determines which socket function to invoke.  I<args> points "
7418 "to a block containing the actual arguments, which are passed through to the "
7419 "appropriate call."
7420 msgstr ""
7421
7422 #. type: Plain text
7423 #: build/C/man2/socketcall.2:42
7424 msgid ""
7425 "User programs should call the appropriate functions by their usual names.  "
7426 "Only standard library implementors and kernel hackers need to know about "
7427 "B<socketcall>()."
7428 msgstr ""
7429
7430 #. type: Plain text
7431 #: build/C/man2/socketcall.2:45
7432 msgid ""
7433 "This call is specific to Linux, and should not be used in programs intended "
7434 "to be portable."
7435 msgstr ""
7436
7437 #. type: Plain text
7438 #: build/C/man2/socketcall.2:53
7439 msgid ""
7440 "On a some architectures\\(emfor example, x86-64 and ARM\\(emthere is no "
7441 "B<socketcall>()  system call; instead B<socket>(2), B<accept>(2), "
7442 "B<bind>(2), and so on really are implemented as separate system calls."
7443 msgstr ""
7444
7445 #. type: Plain text
7446 #: build/C/man2/socketcall.2:71
7447 msgid ""
7448 "B<accept>(2), B<bind>(2), B<connect>(2), B<getpeername>(2), "
7449 "B<getsockname>(2), B<getsockopt>(2), B<listen>(2), B<recv>(2), "
7450 "B<recvfrom>(2), B<recvmsg>(2), B<send>(2), B<sendmsg>(2), B<sendto>(2), "
7451 "B<setsockopt>(2), B<shutdown>(2), B<socket>(2), B<socketpair>(2)"
7452 msgstr ""
7453
7454 #. type: TH
7455 #: build/C/man2/socketpair.2:42
7456 #, no-wrap
7457 msgid "SOCKETPAIR"
7458 msgstr ""
7459
7460 #. type: TH
7461 #: build/C/man2/socketpair.2:42
7462 #, no-wrap
7463 msgid "2008-10-11"
7464 msgstr ""
7465
7466 #. type: Plain text
7467 #: build/C/man2/socketpair.2:45
7468 msgid "socketpair - create a pair of connected sockets"
7469 msgstr ""
7470
7471 #. type: Plain text
7472 #: build/C/man2/socketpair.2:52
7473 msgid ""
7474 "B<int socketpair(int >I<domain>B<, int >I<type>B<, int >I<protocol>B<, int "
7475 ">I<sv>B<[2]);>"
7476 msgstr ""
7477
7478 #. type: Plain text
7479 #: build/C/man2/socketpair.2:63
7480 msgid ""
7481 "The B<socketpair>()  call creates an unnamed pair of connected sockets in "
7482 "the specified I<domain>, of the specified I<type>, and using the optionally "
7483 "specified I<protocol>.  For further details of these arguments, see "
7484 "B<socket>(2)."
7485 msgstr ""
7486
7487 #. type: Plain text
7488 #: build/C/man2/socketpair.2:69
7489 msgid ""
7490 "The descriptors used in referencing the new sockets are returned in I<sv>[0] "
7491 "and I<sv>[1].  The two sockets are indistinguishable."
7492 msgstr ""
7493
7494 #. type: Plain text
7495 #: build/C/man2/socketpair.2:78
7496 msgid "The specified address family is not supported on this machine."
7497 msgstr ""
7498
7499 #. type: Plain text
7500 #: build/C/man2/socketpair.2:83
7501 msgid ""
7502 "The address I<sv> does not specify a valid part of the process address "
7503 "space."
7504 msgstr ""
7505
7506 #. type: Plain text
7507 #: build/C/man2/socketpair.2:86
7508 msgid "Too many descriptors are in use by this process."
7509 msgstr ""
7510
7511 #. type: Plain text
7512 #: build/C/man2/socketpair.2:92
7513 msgid "The specified protocol does not support creation of socket pairs."
7514 msgstr ""
7515
7516 #. type: Plain text
7517 #: build/C/man2/socketpair.2:95
7518 msgid "The specified protocol is not supported on this machine."
7519 msgstr ""
7520
7521 #. type: Plain text
7522 #: build/C/man2/socketpair.2:103
7523 msgid ""
7524 "4.4BSD, POSIX.1-2001.  The B<socketpair>()  function call appeared in "
7525 "4.2BSD.  It is generally portable to/from non-BSD systems supporting clones "
7526 "of the BSD socket layer (including System V variants)."
7527 msgstr ""
7528
7529 #. type: Plain text
7530 #: build/C/man2/socketpair.2:109
7531 msgid ""
7532 "On Linux, the only supported domain for this call is B<AF_UNIX> (or "
7533 "synonymously, B<AF_LOCAL>).  (Most implementations have the same "
7534 "restriction.)"
7535 msgstr ""
7536
7537 #. type: Plain text
7538 #: build/C/man2/socketpair.2:118
7539 msgid ""
7540 "Since Linux 2.6.27, B<socketpair>()  supports the B<SOCK_NONBLOCK> and "
7541 "B<SOCK_CLOEXEC> flags described in B<socket>(2)."
7542 msgstr ""
7543
7544 #. type: Plain text
7545 #: build/C/man2/socketpair.2:131
7546 msgid "B<pipe>(2), B<read>(2), B<socket>(2), B<write>(2), B<socket>(7), B<unix>(7)"
7547 msgstr ""