OSDN Git Service

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