I have a simple client server program that I made but the main issue is that once a connection is established between the client and server, if the client closes the program, the server repeatedly executes the last message and that creates huge problems sometimes. So what I want to is if there is any function that I can call to get the state of a SOCKET structure so if the client closes the program, the server will know to stop. I just need the function what to look for from the function for a bad socket. By the way I am writing this program in Win32 c. I tried if(mySocket==SOCKET_ERROR) which didn't seem to work... unless I used it wrong. I'm just beginning networking.
if(!sockServer.RecvData( recMessage, STRLEN )){return 0;}
// where
bool Socket::RecvData( char *buffer, int size )
{
int i = recv( mySocket, buffer, size, 0 );
if(!i){return false;}
buffer[i] = '\0';
return true;
} //this isn't working