Windows下tcp/udp协议select的FD_SETSIZE轻松修改(MSDN)

xingyun86 2021-6-16 1699

Four macros are defined in the header file Winsock2.h for manipulating and checking the descriptor sets. The variable FD_SETSIZE determines the maximum number of descriptors in a set. (The default value of FD_SETSIZE is 64, which can be modified by defining FD_SETSIZE to another value before including Winsock2.h.) Internally, socket handles in an fd_set structure are not represented as bit flags as in Berkeley Unix. Their data representation is opaque. Use of these macros will maintain software portability between different socket environments. The macros to manipulate and check fd_set contents are:

  • FD_ZERO(*set) - Initializes set to the empty set. A set should always be cleared before using.
  • FD_CLR(s, *set) - Removes socket s from set.
  • FD_ISSET(s, *set) - Checks to see if s is a member of set and returns TRUE if so.
  • FD_SET(s, *set) - Adds socket s to set.

From:

https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-select

×
打赏作者
最新回复 (0)
只看楼主
全部楼主
返回