Article ID: 111855 - View products that this article applies to.
This article was previously published under Q111855
The maximum number of sockets supported by a particular Windows Sockets supplier is implementation-specific. An application should make no assumptions about the availability of a certain number of sockets.
Details of the Windows Sockets implementation are described in the WSAData structure returned by WSAStartup() and defined as follows:
On return from WSAStart() on Windows NT
where iMaxSockets is the maximum number of sockets that a single process can potentially open. A Windows Sockets implementation can provide a global pool of sockets for allocation to any process, or it can allocate per-process resources for sockets. The number can reflect the way in which the Windows Sockets DLL or the networking software was configured. The number can also be used when writing an application as an indication of whether the Windows Sockets implementation can be used by the application.
For example, an X Windows server might check iMaxSockets when it starts. If the number of sockets is less than 8, the application displays an error message instructing the user to reconfigure the networking software. (This is a situation in which the szSystemStatus text might be used.) There is no guarantee that a particular application can actually allocate iMaxSockets sockets, because there may be other Windows Sockets applications in use.
However, independent of the number of sockets supported by a particular implementation is the issue of the maximum number of sockets that an application can actually use.
The maximum number of sockets that a Windows Sockets application can use is determined at compile time by the manifest constant FD_SETSIZE. To do this, from the Win32 SDK WINSOCK.H file:
This value is used in constructing the fd_set structures used in select(). The default value in WINSOCK.H is 64. If an application is designed to be capable of working with more than 64 sockets, define the manifest FD_SETSIZE in every source file before including WINSOCK.H. One way of doing this is to include the definition within the compiler options in the makefile, such as adding -DFD_SETSIZE=128 as an option to the compiler command line for Microsoft C.
NOTE: Defining FD_SETSIZE as a particular value has no effect on the actual number of sockets provided by a Windows Sockets implementation.
Article ID: 111855 - Last Review: November 1, 2006 - Revision: 3.1