question on socket connection
how do you check if the socket has been disconnected?
readSet = socketSet;
if ( select( highestSocketValue + 1, &readSet, NULL, NULL, NULL ) > -1 )
{
.
.
.
if ( FD_ISSET( mySocket, &readSet ) )
{
size = recv( mySocket, message, MAX_MSG_SIZE - 1, 0 );
if ( size == 0 )
{
close( mySocket );
FD_CLR( mySocket, &socketSet );
}
else
{
printf( "%s\n", message );
}
}
.
.
.}
Quoted 1 line · Lejanson C. Go
how do you check if the socket has been disconnected?
Try reading from it; if read/recv return zero bytes, it's closed.
Signature · 1 line
Glynn Clements <[email protected]>