⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 select.2

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 2
字号:
.\" @(#)select.2 1.37 90/02/01 SMI; from UCB 4.2.\" Copyright (c) 1983 Regents of the University of California..\" All rights reserved.  The Berkeley software License Agreement.\" specifies the terms and conditions for redistribution..\".TH select 2.SH Nameselect \- synchronous I/O multiplexing.SH Syntax.nf#include <sys/types.h>#include <sys/time.h>int select (\fInfds\fP, \fIreadfds\fP, \fIwritefds\fP, \fIexceptfds\fP, \fItimeout\fP)int \fInfsd\fP;fd_set \fI*readfds\fP, \fI*writefds\fP, \fI*exceptfds\fP;struct timeval *\fItimeout\fP;FD_SET (\fIfd, fdset\fP)FD_CLR (\fIfd, fdset\fP)FD_ISSET (\fIfd, fdset\fP)FD_ZERO (\fIfdset\fP)int \fIfd\fP;fd_set \fI*fdset\fP;.fi.SH Description.NXR "select system call".NXR "I/O multiplexing"The.PN select system call examines the I/O descriptor sets whose addressesare passed in \fIreadfds\fP, \fIwritefds\fP, and \fIexceptfds\fP to see ifsome of their descriptors are ready for reading, ready forwriting, or have an exception condition pending. The \fInfds\fPparameter isthe number of bits to be checked in each bit mask thatrepresent a file descriptor; the descriptors from 0 through\fInfds\fP-1 in the descriptor sets are examined. Typically\fInfds\fP has the value returned by .MS getdtablesize 2for the maximumnumber of file descriptors. On return, .PN selectreplacesthe given descriptor sets with subsets consisting of thosedescriptors that are ready for the requested operation. Thetotal number of ready descriptors in all the sets isreturned..PPThe descriptor sets are stored as bit fields in arrays ofintegers. The following macros are provided for manipulating such descriptor sets: .RS 5.TP 20FD_ZERO(\fIfdset\fP)Initializes  adescriptor set \fIfdset\fP to the null set. .TPFD_SET(\fIfd\fP, \fIfdset\fP)Includes a particular descriptor \fIfd\fP in \fIfdset\fP. .TPFD_CLR(\fIfd\fP, \fIfdset\fP) Removes \fIfd\fP from \fIfdset\fP. .TPFD_ISSET(\fIfd\fP, \fIfdset\fP) Isnonzero if \fIfd\fP is a member of \fIfdset\fP; otherwise the value isset to zero. .RE.PPThebehavior of these macros is undefined if a descriptor valueis less than zero or greater than or equal to FD_SETSIZE,which is equal to the maximum number ofdescriptors that can be supported by the system..PPIf \fItimeout\fP is not a NULL pointer, it specifies a maximuminterval to wait for the selection to complete. If \fItimeout\fPis a NULL pointer, the .PN select call blocks indefinitely. Toeffect a poll, the \fItimeout\fP argument should be a non-NULLpointer, pointing to a zero-valued timeval structure..PPAny of \fIreadfds\fP, \fIwritefds\fP, and \fIexceptfds\fP may be given as NULLpointers if no descriptors are of interest..PPSelecting true for reading on a socket descriptor upon whicha .PN listen call has been performed indicates that a subsequent .PN acceptcall on that descriptor will not block..SH RestrictionsThe.PN selectcall may indicate that adescriptor is ready for writing when in fact an attempt towrite would block. This can happen if system resourcesnecessary for a write are exhausted or otherwise unavailable. If an application deems it critical that writes to afile descriptor not block, it should set the descriptor fornon-blocking I/O using the F_SETFL request to the.PN fcntlcall..SH Return ValuesThe .PN selectcall returns a non-negative value on success. A positive value indicates the number of ready descriptors in thedescriptor sets. A 0 indicates that the time limit referredto by \fItimeout\fP expired. On failure, .PN selectreturns -1,sets errno to indicate the error, and does not change the descriptor sets..SH Diagnostics.TP 12[EBADF]One of the descriptor sets specified an invalid descriptor..TP[EFAULT]One of the pointers given in the call referred to a non-existent portion of the process's address space..TP[EINTR]A signal was delivered before any of the selected events occurred, or before the time limit expired..TP[EINVAL]A component of the pointed-to time limit is outside the acceptable range. The t_sec range must be between 0 and 10^8, inclusive; t_usec must be greater than or equal to 0, and less than 10^6..SH See Alsoaccept(2), connect(2), fcntl(2), gettimeofday(2), listen(2), read(2), recv(2), send(2), write(2), getdtablesize(2)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -