Maximum Number of Sockets Supported

The maximum number of sockets supported by a particular Windows Sockets service provider is implementation specific. The Microsoft Winsock provider limits the maximum number of sockets supported only by available memory on the local computer. However, third-party Winsock providers may have limitations on the numbers of sockets supported. An application should make no assumptions about the availability of a certain number of sockets. For more information on this topic see WSAStartup.

FD_SET and select

A number of FD_XXX macros are defined in the Winsock2.h header file for use in porting applications to Windows from the UNIX environment. These macros are used with the select and WSAPoll functions for porting applications to Windows. The maximum number of sockets that a Windows Sockets application can use is not affected by the manifest constant FD_SETSIZE. This value defined in the Winsock2.h header file is used in constructing the fd_set structures used with select function. The default value in Winsock2.h is 64. If an application is designed to be capable of working with more than 64 sockets using the select and WSAPoll functions, the implementor should define the manifest FD_SETSIZE in every source file before including the Winsock2.h header file. One way of doing this may be to include the definition within the compiler options in the makefile. For example, you could add "-DFD_SETSIZE=128" as an option to the compiler command line for Microsoft C++. It must be emphasized that defining FD_SETSIZE as a particular value has no effect on the actual number of sockets provided by a Windows Sockets service provider. This value only affects the FD_XXX macros used by the select and WSAPoll functions.

fd_set

Porting Socket Applications to Winsock

select

Winsock Programming Considerations

WSAStartup

WSAPoll