OSDN Git Service

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