# SOME DESCRIPTIVE TITLE # Copyright (C) YEAR Free Software Foundation, Inc. # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "POT-Creation-Date: 2012-03-22 04:26+0900\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" #. type: TH #: build/C/man2/accept.2:39 #, no-wrap msgid "ACCEPT" msgstr "" #. type: TH #: build/C/man2/accept.2:39 #, no-wrap msgid "2010-09-10" msgstr "" #. type: TH #: 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 #, no-wrap msgid "Linux" msgstr "" #. type: TH #: 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 #, no-wrap msgid "Linux Programmer's Manual" msgstr "" #. type: SH #: 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 #, no-wrap msgid "NAME" msgstr "" #. type: Plain text #: build/C/man2/accept.2:42 msgid "accept - accept a connection on a socket" msgstr "" #. type: SH #: 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 #, no-wrap msgid "SYNOPSIS" msgstr "" #. type: Plain text #: build/C/man2/accept.2:46 build/C/man2/bind.2:73 #, no-wrap msgid "" "B<#include Esys/types.hE> /* See NOTES */\n" "B<#include Esys/socket.hE>\n" msgstr "" #. type: Plain text #: build/C/man2/accept.2:48 #, no-wrap msgid "" "BIB<, struct sockaddr *>IB<, socklen_t " "*>IB<);>\n" msgstr "" #. type: Plain text #: build/C/man2/accept.2:51 #, no-wrap msgid "" "B<#define _GNU_SOURCE> /* See feature_test_macros(7) */\n" "B<#include Esys/socket.hE>\n" msgstr "" #. type: Plain text #: build/C/man2/accept.2:54 #, no-wrap msgid "" "BIB<, struct sockaddr *>IB<,>\n" "B< socklen_t *>IB<, int >IB<);>\n" msgstr "" #. type: SH #: 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 #, no-wrap msgid "DESCRIPTION" msgstr "" #. type: Plain text #: build/C/man2/accept.2:70 msgid "" "The B() system call is used with connection-based socket types " "(B, B). It extracts the first connection " "request on the queue of pending connections for the listening socket, " "I, creates a new connected socket, and returns a new file descriptor " "referring to that socket. The newly created socket is not in the listening " "state. The original socket I is unaffected by this call." msgstr "" #. type: Plain text #: build/C/man2/accept.2:79 msgid "" "The argument I is a socket that has been created with B(2), " "bound to a local address with B(2), and is listening for connections " "after a B(2)." msgstr "" #. type: Plain text #: build/C/man2/accept.2:97 msgid "" "The argument I is a pointer to a I structure. This " "structure is filled in with the address of the peer socket, as known to the " "communications layer. The exact format of the address returned I is " "determined by the socket's address family (see B(2) and the " "respective protocol man pages). When I is NULL, nothing is filled in; " "in this case, I is not used, and should also be NULL." msgstr "" #. type: Plain text #: build/C/man2/accept.2:105 msgid "" "The I argument is a value-result argument: the caller must " "initialize it to contain the size (in bytes) of the structure pointed to by " "I; on return it will contain the actual size of the peer address." msgstr "" #. type: Plain text #: build/C/man2/accept.2:110 build/C/man2/getsockname.2:65 msgid "" "The returned address is truncated if the buffer provided is too small; in " "this case, I will return a value greater than was supplied to the " "call." msgstr "" #. type: Plain text #: build/C/man2/accept.2:123 msgid "" "If no pending connections are present on the queue, and the socket is not " "marked as nonblocking, B() blocks the caller until a connection is " "present. If the socket is marked nonblocking and no pending connections are " "present on the queue, B() fails with the error B or " "B." msgstr "" #. type: Plain text #: build/C/man2/accept.2:137 msgid "" "In order to be notified of incoming connections on a socket, you can use " "B(2) or B(2) return a readability event because the " "connection might have been removed by an asynchronous network error or " "another thread before B() is called. If this happens then the call " "will block waiting for the next connection to arrive. To ensure that " "B() never blocks, the passed socket I needs to have the " "B flag set (see B(7))." msgstr "" #. type: SS #: build/C/man2/accept.2:349 #, no-wrap msgid "The socklen_t type" msgstr "" #. type: Plain text #: build/C/man2/accept.2:359 msgid "" "The third argument of B() was originally declared as an I " "(and is that under libc4 and libc5 and on many other systems like 4.x BSD, " "SunOS 4, SGI); a POSIX.1g draft standard wanted to change it into a I, and that is what it is for SunOS 5. Later POSIX drafts have I, and so do the Single UNIX Specification and glibc2. Quoting Linus " "Torvalds:" msgstr "" #. .I fails: only italicizes a single line #. type: Plain text #: build/C/man2/accept.2:376 msgid "" "\"_Any_ sane library _must_ have \"socklen_t\" be the same size as int. " "Anything else breaks any BSD socket layer stuff. POSIX initially I " "make it a size_t, and I (and hopefully others, but obviously not too many) " "complained to them very loudly indeed. Making it a size_t is completely " "broken, exactly because size_t very seldom is the same size as \"int\" on " "64-bit architectures, for example. And it I to be the same size as " "\"int\" because that's what the BSD socket interface is. Anyway, the POSIX " "people eventually got a clue, and created \"socklen_t\". They shouldn't " "have touched it in the first place, but once they did they felt it had to " "have a named type for some unfathomable reason (probably somebody didn't " "like losing face over having done the original stupid thing, so they " "silently just renamed their blunder).\"" msgstr "" #. type: SH #: build/C/man2/accept.2:376 build/C/man2/bind.2:252 build/C/man2/connect.2:256 build/C/man3/getifaddrs.3:198 build/C/man2/listen.2:164 build/C/man2/recv.2:488 build/C/man2/select.2:482 build/C/man2/select_tut.2:527 build/C/man2/send.2:414 build/C/man3/sockatmark.3:95 build/C/man2/socket.2:382 #, no-wrap msgid "EXAMPLE" msgstr "" #. type: Plain text #: build/C/man2/accept.2:379 build/C/man2/listen.2:167 msgid "See B(2)." msgstr "" #. type: SH #: build/C/man2/accept.2:379 build/C/man2/bind.2:317 build/C/man3/bindresvport.3:98 build/C/man2/connect.2:261 build/C/man3/getifaddrs.3:281 build/C/man2/getsockname.2:110 build/C/man2/getsockopt.2:200 build/C/man2/listen.2:167 build/C/man2/recv.2:493 build/C/man2/recvmmsg.2:165 build/C/man2/select.2:519 build/C/man2/select_tut.2:817 build/C/man2/send.2:419 build/C/man2/sendmmsg.2:168 build/C/man3/sockatmark.3:130 build/C/man2/socket.2:387 build/C/man7/socket.7:742 build/C/man2/socketcall.2:54 build/C/man2/socketpair.2:122 #, no-wrap msgid "SEE ALSO" msgstr "" #. type: Plain text #: build/C/man2/accept.2:386 msgid "" "B(2), B(2), B(2), B(2) or B(2) for completion " "by selecting the socket for writing. After B(2) or B(2) call may be used to determine when more " "data arrives." msgstr "" #. type: Plain text #: build/C/man2/recv.2:133 msgid "" "The I argument to a B() call is formed by ORing one or more of " "the following values:" msgstr "" #. type: TP #: build/C/man2/recv.2:133 #, no-wrap msgid "B (B() only; since Linux 2.6.23)" msgstr "" #. type: Plain text #: build/C/man2/recv.2:144 msgid "" "Set the close-on-exec flag for the file descriptor received via a UNIX " "domain file descriptor using the B operation (described in " "B(7)). This flag is useful for the same reasons as the B " "flag of B(2)." msgstr "" #. type: TP #: build/C/man2/recv.2:144 build/C/man2/send.2:186 #, no-wrap msgid "B (since Linux 2.2)" msgstr "" #. type: Plain text #: build/C/man2/recv.2:154 msgid "" "Enables nonblocking operation; if the operation would block, the call fails " "with the error B or B (this can also be enabled using " "the B flag with the B B(2))." msgstr "" #. type: TP #: build/C/man2/recv.2:154 #, no-wrap msgid "B (since Linux 2.2)" msgstr "" #. type: Plain text #: build/C/man2/recv.2:173 msgid "" "This flag specifies that queued errors should be received from the socket " "error queue. The error is passed in an ancillary message with a type " "dependent on the protocol (for IPv4 B). The user should supply " "a buffer of sufficient size. See B(3) and B(7) for more " "information. The payload of the original packet that caused the error is " "passed as normal data via I. The original destination address of " "the datagram that caused the error is supplied via I." msgstr "" #. type: Plain text #: build/C/man2/recv.2:185 build/C/man2/recv.2:248 msgid "" "For local errors, no address is passed (this can be checked with the " "I member of the I). For error receives, the " "B is set in the I. After an error has been passed, " "the pending socket error is regenerated based on the next queued error and " "will be passed on the next socket operation." msgstr "" #. type: Plain text #: build/C/man2/recv.2:189 msgid "The error is supplied in a I structure:" msgstr "" #. type: Plain text #: build/C/man2/recv.2:196 #, no-wrap msgid "" "#define SO_EE_ORIGIN_NONE 0\n" "#define SO_EE_ORIGIN_LOCAL 1\n" "#define SO_EE_ORIGIN_ICMP 2\n" "#define SO_EE_ORIGIN_ICMP6 3\n" msgstr "" #. type: Plain text #: build/C/man2/recv.2:208 #, no-wrap msgid "" "struct sock_extended_err\n" "{\n" " uint32_t ee_errno; /* error number */\n" " uint8_t ee_origin; /* where the error originated */\n" " uint8_t ee_type; /* type */\n" " uint8_t ee_code; /* code */\n" " uint8_t ee_pad; /* padding */\n" " uint32_t ee_info; /* additional information */\n" " uint32_t ee_data; /* other data */\n" " /* More data may follow */\n" "};\n" msgstr "" #. type: Plain text #: build/C/man2/recv.2:210 #, no-wrap msgid "struct sockaddr *SO_EE_OFFENDER(struct sock_extended_err *);\n" msgstr "" #. type: Plain text #: build/C/man2/recv.2:234 msgid "" "I contains the I number of the queued error. I " "is the origin code of where the error originated. The other fields are " "protocol-specific. The macro B returns a pointer to the " "address of the network object where the error originated from given a " "pointer to the ancillary message. If this address is not known, the " "I member of the I contains B and the other " "fields of the I are undefined. The payload of the packet that " "caused the error is passed as normal data." msgstr "" #. type: TP #: build/C/man2/recv.2:248 build/C/man2/recv.2:379 build/C/man2/send.2:228 #, no-wrap msgid "B" msgstr "" #. type: Plain text #: build/C/man2/recv.2:255 msgid "" "This flag requests receipt of out-of-band data that would not be received in " "the normal data stream. Some protocols place expedited data at the head of " "the normal data queue, and thus this flag cannot be used with such " "protocols." msgstr "" #. type: TP #: build/C/man2/recv.2:255 #, no-wrap msgid "B" msgstr "" #. type: Plain text #: build/C/man2/recv.2:262 msgid "" "This flag causes the receive operation to return data from the beginning of " "the receive queue without removing that data from the queue. Thus, a " "subsequent receive call will return the same data." msgstr "" #. type: TP #: build/C/man2/recv.2:262 #, no-wrap msgid "B (since Linux 2.2)" msgstr "" #. type: Plain text #: build/C/man2/recv.2:273 msgid "" "For raw (B), Internet datagram (since Linux 2.4.27/2.6.8), and " "netlink (since Linux 2.6.22) sockets: return the real length of the packet " "or datagram, even when it was longer than the passed buffer. Not " "implemented for UNIX domain (B(7)) sockets." msgstr "" #. type: Plain text #: build/C/man2/recv.2:276 msgid "For use with Internet stream sockets, see B(7)." msgstr "" #. type: TP #: build/C/man2/recv.2:276 #, no-wrap msgid "B (since Linux 2.2)" msgstr "" #. type: Plain text #: build/C/man2/recv.2:283 msgid "" "This flag requests that the operation block until the full request is " "satisfied. However, the call may still return less data than requested if a " "signal is caught, an error or disconnect occurs, or the next data to be " "received is of a different type than that returned." msgstr "" #. type: Plain text #: build/C/man2/recv.2:291 msgid "" "The B() call uses a I structure to minimize the number of " "directly supplied arguments. This structure is defined as follows in " "Isys/socket.hE>:" msgstr "" #. type: Plain text #: build/C/man2/recv.2:298 #, no-wrap msgid "" "struct iovec { /* Scatter/gather array items */\n" " void *iov_base; /* Starting address */\n" " size_t iov_len; /* Number of bytes to transfer */\n" "};\n" msgstr "" #. type: Plain text #: build/C/man2/recv.2:308 build/C/man2/send.2:256 #, no-wrap msgid "" "struct msghdr {\n" " void *msg_name; /* optional address */\n" " socklen_t msg_namelen; /* size of address */\n" " struct iovec *msg_iov; /* scatter/gather array */\n" " size_t msg_iovlen; /* # elements in msg_iov */\n" " void *msg_control; /* ancillary data, see below */\n" " size_t msg_controllen; /* ancillary data buffer len */\n" " int msg_flags; /* flags on received message */\n" "};\n" msgstr "" #. type: Plain text #: build/C/man2/recv.2:338 msgid "" "Here I and I specify the source address if the socket " "is unconnected; I may be given as a NULL pointer if no names are " "desired or required. The fields I and I describe " "scatter-gather locations, as discussed in B(2). The field " "I, which has length I, points to a buffer for " "other protocol control-related messages or miscellaneous ancillary data. " "When B() is called, I should contain the length of " "the available buffer in I; upon return from a successful call " "it will contain the length of the control message sequence." msgstr "" #. type: Plain text #: build/C/man2/recv.2:340 msgid "The messages are of the form:" msgstr "" #. type: Plain text #: build/C/man2/recv.2:350 #, no-wrap msgid "" "struct cmsghdr {\n" " socklen_t cmsg_len; /* data byte count, including hdr */\n" " int cmsg_level; /* originating protocol */\n" " int cmsg_type; /* protocol-specific type */\n" "/* followed by\n" " unsigned char cmsg_data[]; */\n" "};\n" msgstr "" #. type: Plain text #: build/C/man2/recv.2:355 msgid "Ancillary data should only be accessed by the macros defined in B(3)." msgstr "" #. type: Plain text #: build/C/man2/recv.2:358 msgid "" "As an example, Linux uses this ancillary data mechanism to pass extended " "errors, IP options, or file descriptors over UNIX domain sockets." msgstr "" #. type: Plain text #: build/C/man2/recv.2:366 msgid "" "The I field in the I is set on return of B(). " "It can contain several flags:" msgstr "" #. type: TP #: build/C/man2/recv.2:366 #, no-wrap msgid "B" msgstr "" #. type: Plain text #: build/C/man2/recv.2:371 msgid "" "indicates end-of-record; the data returned completed a record (generally " "used with sockets of type B)." msgstr "" #. type: TP #: build/C/man2/recv.2:371 #, no-wrap msgid "B" msgstr "" #. type: Plain text #: build/C/man2/recv.2:375 msgid "" "indicates that the trailing portion of a datagram was discarded because the " "datagram was larger than the buffer supplied." msgstr "" #. type: TP #: build/C/man2/recv.2:375 #, no-wrap msgid "B" msgstr "" #. type: Plain text #: build/C/man2/recv.2:379 msgid "" "indicates that some control data were discarded due to lack of space in the " "buffer for ancillary data." msgstr "" #. type: Plain text #: build/C/man2/recv.2:382 msgid "is returned to indicate that expedited or out-of-band data were received." msgstr "" #. type: TP #: build/C/man2/recv.2:382 #, no-wrap msgid "B" msgstr "" #. type: Plain text #: build/C/man2/recv.2:386 msgid "" "indicates that no data was received but an extended error from the socket " "error queue." msgstr "" #. type: Plain text #: build/C/man2/recv.2:391 msgid "" "These calls return the number of bytes received, or -1 if an error " "occurred. The return value will be 0 when the peer has performed an orderly " "shutdown." msgstr "" #. type: Plain text #: build/C/man2/recv.2:396 msgid "" "These are some standard errors generated by the socket layer. Additional " "errors may be generated and returned from the underlying protocol modules; " "see their manual pages." msgstr "" #. Actually EAGAIN on Linux #. type: Plain text #: build/C/man2/recv.2:405 msgid "" "The socket is marked nonblocking and the receive operation would block, or a " "receive timeout had been set and the timeout expired before data was " "received. POSIX.1-2001 allows either error to be returned for this case, " "and does not require these constants to have the same value, so a portable " "application should check for both possibilities." msgstr "" #. type: Plain text #: build/C/man2/recv.2:410 msgid "The argument I is an invalid descriptor." msgstr "" #. type: Plain text #: build/C/man2/recv.2:414 msgid "" "A remote host refused to allow the network connection (typically because it " "is not running the requested service)." msgstr "" #. type: Plain text #: build/C/man2/recv.2:418 msgid "The receive buffer pointer(s) point outside the process's address space." msgstr "" #. type: Plain text #: build/C/man2/recv.2:423 msgid "" "The receive was interrupted by delivery of a signal before any data were " "available; see B(7)." msgstr "" #. type: Plain text #: build/C/man2/recv.2:427 build/C/man2/send.2:318 msgid "Invalid argument passed." msgstr "" #. type: Plain text #: build/C/man2/recv.2:431 msgid "Could not allocate memory for B()." msgstr "" #. type: TP #: build/C/man2/recv.2:431 build/C/man2/send.2:341 #, no-wrap msgid "B" msgstr "" #. type: Plain text #: build/C/man2/recv.2:438 msgid "" "The socket is associated with a connection-oriented protocol and has not " "been connected (see B(2) and B(2))." msgstr "" #. type: Plain text #: build/C/man2/recv.2:443 msgid "The argument I does not refer to a socket." msgstr "" #. type: Plain text #: build/C/man2/recv.2:446 msgid "4.4BSD (these function calls first appeared in 4.2BSD), POSIX.1-2001." msgstr "" #. type: Plain text #: build/C/man2/recv.2:453 msgid "" "POSIX.1-2001 only describes the B, B, and B " "flags." msgstr "" #. type: Plain text #: build/C/man2/recv.2:469 msgid "" "The prototypes given above follow glibc2. The Single UNIX Specification " "agrees, except that it has return values of type I (while 4.x BSD " "and libc4 and libc5 all have I). The I argument is I in " "4.x BSD, but I in libc4 and libc5. The I argument is " "I in 4.x BSD, but I in libc4 and libc5. The I " "argument is I in 4.x BSD, libc4 and libc5. The present " "I was invented by POSIX. See also B(2)." msgstr "" #. glibc bug raised 12 Mar 2006 #. http://sourceware.org/bugzilla/show_bug.cgi?id=2448 #. The problem is an underlying kernel issue: the size of the #. __kernel_size_t type used to type this field varies #. across architectures, but socklen_t is always 32 bits. #. type: Plain text #: build/C/man2/recv.2:483 build/C/man2/send.2:404 msgid "" "According to POSIX.1-2001, the I field of the I " "structure should be typed as I, but glibc currently types it as " "I." msgstr "" #. type: Plain text #: build/C/man2/recv.2:488 msgid "" "See B for information about a Linux-specific system call that " "can be used to receive multiple datagrams in a single call." msgstr "" #. type: Plain text #: build/C/man2/recv.2:493 msgid "An example of the use of B() is shown in B(3)." msgstr "" #. type: Plain text #: build/C/man2/recv.2:504 msgid "" "B(2), B(2), B(2), B(2), B() and B() allow a program to monitor multiple file " "descriptors, waiting until one or more of the file descriptors become " "\"ready\" for some class of I/O operation (e.g., input possible). A file " "descriptor is considered ready if it is possible to perform the " "corresponding I/O operation (e.g., B(2)) without blocking." msgstr "" #. type: Plain text #: build/C/man2/select.2:98 msgid "" "The operation of B() uses a timeout that is a I (with seconds and " "microseconds), while B() uses a I (with seconds " "and nanoseconds)." msgstr "" #. type: TP #: build/C/man2/select.2:108 #, no-wrap msgid "(ii)" msgstr "" #. type: Plain text #: build/C/man2/select.2:116 msgid "" "B() has no I argument, and behaves as B() called " "with NULL I." msgstr "" #. type: Plain text #: build/C/man2/select.2:143 msgid "" "Three independent sets of file descriptors are watched. Those listed in " "I will be watched to see if characters become available for reading " "(more precisely, to see if a read will not block; in particular, a file " "descriptor is also ready on end-of-file), those in I will be " "watched to see if a write will not block, and those in I will be " "watched for exceptions. On exit, the sets are modified in place to indicate " "which file descriptors actually changed status. Each of the three file " "descriptor sets may be specified as NULL if no file descriptors are to be " "watched for the corresponding class of events." msgstr "" #. type: Plain text #: build/C/man2/select.2:156 msgid "" "Four macros are provided to manipulate the sets. B() clears a " "set. B() and B() respectively add and remove a given file " "descriptor from a set. B() tests to see if a file descriptor is " "part of the set; this is useful after B() returns. If both fields of the I structure are zero, " "then B() can block indefinitely." msgstr "" #. type: Plain text #: build/C/man2/select.2:185 msgid "" "I is a pointer to a signal mask (see B(2)); if it is " "not NULL, then B() first replaces the current signal mask by the " "one pointed to by I, then does the \"select\" function, and then " "restores the original signal mask." msgstr "" #. type: Plain text #: build/C/man2/select.2:191 msgid "" "Other than the difference in the precision of the I argument, the " "following B() call:" msgstr "" #. type: Plain text #: build/C/man2/select.2:195 #, no-wrap msgid "" " ready = pselect(nfds, &readfds, &writefds, &exceptfds,\n" " timeout, &sigmask);\n" msgstr "" #. type: Plain text #: build/C/man2/select.2:200 msgid "is equivalent to I executing the following calls:" msgstr "" #. type: Plain text #: build/C/man2/select.2:203 #, no-wrap msgid " sigset_t origmask;\n" msgstr "" #. type: Plain text #: build/C/man2/select.2:207 #, no-wrap msgid "" " sigprocmask(SIG_SETMASK, &sigmask, &origmask);\n" " ready = select(nfds, &readfds, &writefds, &exceptfds, timeout);\n" " sigprocmask(SIG_SETMASK, &origmask, NULL);\n" msgstr "" #. type: Plain text #: build/C/man2/select.2:228 msgid "" "The reason that B() is needed is that if one wants to wait for " "either a signal or for a file descriptor to become ready, then an atomic " "test is needed to prevent race conditions. (Suppose the signal handler sets " "a global flag and returns. Then a test of this global flag followed by a " "call of B() with all three sets empty, I zero, and a " "non-NULL I as a fairly portable way to sleep with subsecond " "precision." msgstr "" #. .PP - it is rumored that: #. On BSD, when a timeout occurs, the file descriptor bits are not changed. #. - it is certainly true that: #. Linux follows SUSv2 and sets the bit masks to zero upon a timeout. #. type: Plain text #: build/C/man2/select.2:285 msgid "" "On Linux, B()s in a loop " "without reinitializing it. Consider I to be undefined after " "B() and B() return the number of file " "descriptors contained in the three returned descriptor sets (that is, the " "total number of bits that are set in I, I, I) " "which may be zero if the timeout expires before anything interesting " "happens. On error, -1 is returned, and I is set appropriately; the " "sets and I become undefined, so do not rely on their contents after " "an error." msgstr "" #. type: Plain text #: build/C/man2/select.2:308 msgid "" "An invalid file descriptor was given in one of the sets. (Perhaps a file " "descriptor that was already closed, or one on which an error has occurred.)" msgstr "" #. type: Plain text #: build/C/man2/select.2:312 msgid "A signal was caught; see B(7)." msgstr "" #. type: Plain text #: build/C/man2/select.2:318 msgid "I is negative or the value contained within I is invalid." msgstr "" #. type: Plain text #: build/C/man2/select.2:321 msgid "unable to allocate memory for internal tables." msgstr "" #. type: Plain text #: build/C/man2/select.2:327 msgid "" "B() was added to Linux in kernel 2.6.16. Prior to this, " "B() was emulated in glibc (but see BUGS)." msgstr "" #. type: Plain text #: build/C/man2/select.2:338 msgid "" "B() first " "appeared in 4.2BSD). Generally portable to/from non-BSD systems supporting " "clones of the BSD socket layer (including System V variants). However, note " "that the System V variant typically sets the timeout variable before exit, " "but the BSD variant does not." msgstr "" #. type: Plain text #: build/C/man2/select.2:342 msgid "B() is defined in POSIX.1g, and in POSIX.1-2001." msgstr "" #. type: Plain text #: build/C/man2/select.2:359 msgid "" "An I is a fixed size buffer. Executing B() or B() " "with a value of I that is negative or is equal to or larger than " "B will result in undefined behavior. Moreover, POSIX requires " "I to be a valid file descriptor." msgstr "" #. type: Plain text #: build/C/man2/select.2:368 msgid "" "Concerning the types involved, the classical situation is that the two " "fields of a I structure are typed as I (as shown above), and " "the structure is defined in Isys/time.hE>. The POSIX.1-2001 " "situation is" msgstr "" #. type: Plain text #: build/C/man2/select.2:375 #, no-wrap msgid "" "struct timeval {\n" " time_t tv_sec; /* seconds */\n" " suseconds_t tv_usec; /* microseconds */\n" "};\n" msgstr "" #. type: Plain text #: build/C/man2/select.2:386 msgid "" "where the structure is defined in Isys/select.hE> and the data " "types I and I are defined in Isys/types.hE>." msgstr "" #. type: Plain text #: build/C/man2/select.2:398 msgid "" "Concerning prototypes, the classical situation is that one should include " "Itime.hE> for B() and B()." msgstr "" #. type: Plain text #: build/C/man2/select.2:410 msgid "" "Libc4 and libc5 do not have a Isys/select.hE> header; under glibc " "2.0 and later this header exists. Under glibc 2.0 it unconditionally gives " "the wrong prototype for B(). Under glibc 2.1 to 2.2.1 it gives " "B() when B<_GNU_SOURCE> is defined. Since glibc 2.2.2 the " "requirements are as shown in the SYNOPSIS." msgstr "" #. type: SS #: build/C/man2/select.2:410 #, no-wrap msgid "Linux Notes" msgstr "" #. type: Plain text #: build/C/man2/select.2:423 msgid "" "The Linux B() system call modifies its I argument. " "However, the glibc wrapper function hides this behavior by using a local " "variable for the timeout argument that is passed to the system call. Thus, " "the glibc B() function does not modify its timeout argument; this " "is the behavior required by POSIX.1-2001." msgstr "" #. type: Plain text #: build/C/man2/select.2:429 msgid "" "Glibc 2.0 provided a version of B() that did not take a I " "argument." msgstr "" #. type: Plain text #: build/C/man2/select.2:442 msgid "" "Starting with version 2.1, glibc provided an emulation of B() that " "was implemented using B(2) and B() in the " "main program.)" msgstr "" #. Stevens discusses a case where accept can block after select #. returns successfully because of an intervening RST from the client. #. Maybe the kernel should have returned EIO in such a situation? #. type: Plain text #: build/C/man2/select.2:467 msgid "" "Under Linux, B() also modifies I if the call is interrupted " "by a signal handler (i.e., the B error return). This is not " "permitted by POSIX.1-2001. The Linux B() system call has the same " "behavior, but the glibc wrapper hides this behavior by internally copying " "the I to a local variable and passing that variable to the system " "call." msgstr "" #. type: Plain text #: build/C/man2/select.2:489 #, no-wrap msgid "" "#include Estdio.hE\n" "#include Estdlib.hE\n" "#include Esys/time.hE\n" "#include Esys/types.hE\n" "#include Eunistd.hE\n" msgstr "" #. type: Plain text #: build/C/man2/select.2:496 #, no-wrap msgid "" "int\n" "main(void)\n" "{\n" " fd_set rfds;\n" " struct timeval tv;\n" " int retval;\n" msgstr "" #. type: Plain text #: build/C/man2/select.2:500 #, no-wrap msgid "" " /* Watch stdin (fd 0) to see when it has input. */\n" " FD_ZERO(&rfds);\n" " FD_SET(0, &rfds);\n" msgstr "" #. type: Plain text #: build/C/man2/select.2:504 #, no-wrap msgid "" " /* Wait up to five seconds. */\n" " tv.tv_sec = 5;\n" " tv.tv_usec = 0;\n" msgstr "" #. type: Plain text #: build/C/man2/select.2:507 #, no-wrap msgid "" " retval = select(1, &rfds, NULL, NULL, &tv);\n" " /* Don't rely on the value of tv now! */\n" msgstr "" #. type: Plain text #: build/C/man2/select.2:515 #, no-wrap msgid "" " if (retval == -1)\n" " perror(\"select()\");\n" " else if (retval)\n" " printf(\"Data is available now.\\en\");\n" " /* FD_ISSET(0, &rfds) will be true. */\n" " else\n" " printf(\"No data within five seconds.\\en\");\n" msgstr "" #. type: Plain text #: build/C/man2/select.2:518 #, no-wrap msgid "" " exit(EXIT_SUCCESS);\n" "}\n" msgstr "" #. type: Plain text #: build/C/man2/select.2:522 msgid "For a tutorial with discussion and examples, see B(2)." msgstr "" #. type: Plain text #: build/C/man2/select.2:534 msgid "" "For vaguely related stuff, see B(2), B(2), B(2), " "B(2), B(2), B(2), B(2), B(2), " "B(7), B