OSDN Git Service

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