InetAccept Function  
 
SOCKET WINAPI InetAccept(
  SOCKET hSocket,  
  UINT nTimeout  
);

The InetAccept function is used to accept a client connection on a listening socket.

This function is included for backwards compatibility with legacy applications. New projects should use the InetServerStart function to to create a server application.

Parameters

hSocket
Handle to the listening socket.
nTimeout
The number of seconds that the server will wait for the connection to complete before failing the operation.

Return Value

If the function succeeds, the return value is a handle to the socket. If the function fails, the return value is INVALID_SOCKET. To get extended error information, call InetGetLastError.

Remarks

To prevent this function from blocking the main user interface thread, the application should create a background worker thread and accept the connection by calling InetAccept in that thread. If the application requires multiple simultaneous connections, it is recommended you create a worker thread for each client session.

When a connection is accepted by the server, the original listening socket continues to listen for more connections. The socket handle returned by InetAccept should be used to exchange information with the client.

To enable asynchronous event notification, use the InetEnableEvents function.

Requirements

Minimum Desktop Platform: Windows 7 (Service Pack 1)
Minimum Server Platform: Windows Server 2008 R2 (Service Pack 1)
Header: Include cswsock10.h
Import Library: cswskv10.lib

See Also

InetConnect, InetEnableEvents, InetListen, InetReject, InetServerStart