Graceful disconnection.

Started by
0 comments, last by CheeseMonger 20 years, 3 months ago
Lets say the server wants to disconnect gracefully and there is no pending data to be received by the client. In the non-blocking client:

FD_ZERO(&fdRdSet);		//empty read set
FD_SET(iSocket, &fdRdSet);	//add socket to read set

select(0, &fdRdSet, NULL, NULL, &tTimeout);

//if socket is readable
if (FD_ISSET(iSocket, &fdRdSet))
{
	unsigned long iBytesPending;
	ioctlsocket(iSocket, FIONREAD, &iBytesPending);
} 
An iBytesPending value of zero should indicate a graceful disconnection by the server, correct? - CheeseMonger
- CheeseMonger
Advertisement
In this case, the return value of iBytesPending indicated how much data is available to be read.

Kuphryn

This topic is closed to new replies.

Advertisement