6.5.2 Server Applications and Connect Data
Server applications use connect data differently from client applications in two important ways:
1.A server application receives the client’s connect data before it sends back its own.
2.Because Windows Sockets does not support delayed-connection acceptances as TDI does, a server application must send the same response-connect data to all clients.
To receive connect data sent by clients, a server application calls setsockopt with the SO_CONNDATALEN option to force Windows Sockets to reserve buffer space for receiving connect data for incoming connect requests. The specified amount of connect-data buffer space is used subsequently for all incoming connects, but Windows Sockets allocates a separate buffer for each connect.
After a newly connected socket is accepted with accept, the server application calls getsockopt with the SO_CONNDATA option and a server-allocated buffer large enough to hold the expected data. Windows Sockets fills in this buffer with the connect data sent by the client.
To send response-connect data to clients, a server application calls setsockopt with the SO_CONNDATA option and a buffer of data before any incoming connections are accepted (typically before listen). Thereafter, any client that connects to the server receives that server-supplied connect-response data. The connect-response data for a server can be changed at any time with another setsockopt call, which discards the previous data and replaces it with the new data.