InetServerThrottle
BOOL InetServerThrottle(
SOCKET hServer,  
UINT nMaxClients,  
UINT nMaxClientsPerAddress,  
DWORD dwConnectionRate  
);

The InetServerThrottle function limits the number of active client connections, connections per address and connection rate.

Parameters

hServer
Handle to the server socket.
nMaxClients
A value which specifies the maximum number of clients that may connect to the server. A value of zero specifies that there is no fixed limit to the number of client connections.
nMaxClientsPerAddress
A value which specifies the maximum number of clients that may connect to the server from the same IP address. A value of zero specifies that there is no fixed limit to the number of client connections per address. By default, there is no limit on the number of client connections per address.
dwConnectionRate
A value which specifies a restriction on the rate of client connections, limiting the number of connections that will be accepted within that period of time. A value of zero specifies that there is no restriction on the rate of client connections. The higher this value, the fewer the number of connections that will be accepted within a specific period of time. By default, there is no limit on the client connection rate.

Return Value

If the function succeeds, the return value is non-zero. If the function fails, the return value is zero. To get extended error information, call InetGetLastError.

Remarks

The InetServerThrottle function is used to limit the number of connections and the connection rate to minimize the potential impact of a large number of client connections over a short period of time. This can be used to protect the server from a client application that is malfunctioning or a deliberate denial-of-service attack in which the attacker attempts to flood the server with connection attempts.

If the maximum number of client connections or maximum number of connections per address is exceeded, the server will reject subsequent connection attempts until the number of active client sessions drops below the specified threshold. Note that adjusting these values lower than the current connection limits will not affect clients that have already connected to the server. For example, if the InetServerStart function is called with the maximum number of clients set to 100, and then InetServerThrottle is called lowering that value to 75, no existing client connections will be affected by the change. However, the server will not accept any new connections until the number of active clients drops below 75.

Increasing the connection rate value will force the server to slow down the rate at which it will accept incoming client connection requests. For example, setting this parameter to a value of 1000 would limit the server to accepting one client connection every second, while a value of 250 would allow the server to accept four client connections per second. Note that significantly increasing the amount of time the server must wait to accept client connections can exceed the connection backlog queue, resulting in client connections being rejected.

The socket handle for the server must be one that was created by calling the InetServerStart function, and cannot be a socket that was created using the InetListen or InetListenEx functions.

Requirements

Client: Requires Windows Vista, Windows XP or Windows 2000 Professional.
Server: Requires Windows Server 2008, Windows Server 2003 or Windows 2000 Server.
Header: Include cswsock6.h.
Library: Use cswskav6.lib.

See Also

InetGetServerStatus, InetServerLock, InetServerRestart, InetServerResume, InetServerStart, InetServerSuspend, InetServerUnlock


Copyright © 2008 Catalyst Development Corporation. All rights reserved.