winsock select() 返回值

来源:互联网 发布:excel数据清洗工具 编辑:程序博客网 时间:2024/06/05 10:34

The select function determines the status of one or more sockets, waiting if necessary, to perform synchronous I/O.

Syntax

int select(  __in     int nfds,  __inout  fd_set *readfds,  __inout  fd_set *writefds,  __inout  fd_set *exceptfds,  __in     const struct timeval *timeout);

Parameters

nfds [in]

Ignored. The nfds parameter is included only for compatibility with Berkeley sockets.

readfds [in, out]

An optional pointer to a set of sockets to be checked for readability.

writefds [in, out]

An optional pointer to a set of sockets to be checked for writability.

exceptfds [in, out]

An optional pointer to a set of sockets to be checked for errors.

timeout [in]

The maximum time for select to wait, provided in the form of a TIMEVAL structure. Set the timeout parameter to null for blocking operations.

Return value

The select function returns the total number of socket handles that are ready and contained in the fd_set structures, zero if the time limit expired, or SOCKET_ERROR if an error occurred. If the return value is SOCKET_ERROR, WSAGetLastError can be used to retrieve a specific error code.


1.如果超时返回 0

2.返回fd_set 中准备好的socket个数(不包括零)

3.如果没有准备好的返回 -1


原创粉丝点击