MrDoomMaster
December 10th, 2004, 04:47 PM
Hey guys, I have a small function in a class of mine which will return 1 if the socket is connected, and 0 if it is not connected. I attempt to do this using select() to detect the writability of the socket.
Here is the code:
int WinSock_Utils::B_ConnectionStatus(void)
{
if(OpMode != wsu::NONBLOCKING)
return 0;
FD_ZERO(&SyncState);
if(HostType == wsu::CLIENT)
FD_SET(Socket, &SyncState);
else
FD_SET(ConnectedSocket, &SyncState);
return select(-1, NULL, &SyncState, NULL, &SelectTimer);
}
This returns 1 every time, and never returns 0. The connection is successful to the client, because my client posts text when it is connected. Yet, when I close my client (which calls B_Disconnect member of my class), it properly disconnects using closesocket() and all of that stuff, but the function you see above (which is only used in my server) always returns 1!! Even after the client has been closed! It should return 0!
Any tips? What am I doing wrong?
Thanks! If you need more code, let me know!
Here is the code:
int WinSock_Utils::B_ConnectionStatus(void)
{
if(OpMode != wsu::NONBLOCKING)
return 0;
FD_ZERO(&SyncState);
if(HostType == wsu::CLIENT)
FD_SET(Socket, &SyncState);
else
FD_SET(ConnectedSocket, &SyncState);
return select(-1, NULL, &SyncState, NULL, &SelectTimer);
}
This returns 1 every time, and never returns 0. The connection is successful to the client, because my client posts text when it is connected. Yet, when I close my client (which calls B_Disconnect member of my class), it properly disconnects using closesocket() and all of that stuff, but the function you see above (which is only used in my server) always returns 1!! Even after the client has been closed! It should return 0!
Any tips? What am I doing wrong?
Thanks! If you need more code, let me know!