xingyun86 5月前 192

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.


最新回复 (0)