You are currently offline, waiting for your internet to reconnect

Maximum Number of Sockets an Application Can Use

This article was previously published under Q111855
This article has been archived. It is offered "as is" and will no longer be updated.
The maximum number of sockets supported by a particular Windows Socketssupplier is implementation-specific. An application should make noassumptions about the availability of a certain number of sockets.
Details of the Windows Sockets implementation are described in the WSADatastructure returned by WSAStartup() and defined as follows:
struct WSAData {     WORD          wVersion;     WORD          wHighVersion;     char           szDescription[WSADESCRIPTION_LEN+1];     char          szSystemStatus[WSASYSSTATUS_LEN+1];     unsigned short     iMaxSockets;     unsigned short     iMaxUdpDg;     char FAR *     lpVendorInfo};				
On return from WSAStart() on Windows NT
   iMaxSockets = 0x7fff (32767)				
where iMaxSockets is the maximum number of sockets that a single processcan 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 errormessage instructing the user to reconfigure the networking software. (Thisis 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 particularimplementation is the issue of the maximum number of sockets that anapplication 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:
/* * Select uses arrays of SOCKETs. These macros manipulate such * arrays. FD_SETSIZE may be defined by the user before including * this file, but the default here should be >= 64. * * CAVEAT IMPLEMENTOR and USER: THESE MACROS AND TYPES MUST BE * INCLUDED IN WINSOCK.H EXACTLY AS SHOWN HERE. */ #ifndef FD_SETSIZE#define FD_SETSIZE      64#endif /* FD_SETSIZE */ 				
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 becapable of working with more than 64 sockets, define the manifestFD_SETSIZE in every source file before including WINSOCK.H. One way ofdoing this is to include the definition within the compiler options in themakefile, such as adding -DFD_SETSIZE=128 as an option to the compilercommand 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.
prodnt tcpip

Article ID: 111855 - Last Review: 12/04/2015 10:00:26 - Revision: 3.1

Microsoft Windows NT Advanced Server 3.1, Microsoft Windows NT Workstation 3.1

  • kbnosurvey kbarchive kbnetwork KB111855