OSDN Git Service

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