mirror of
https://github.com/glest/glest-source.git
synced 2025-02-26 04:32:22 +01:00
- added extra check on linux for socket disconnect
This commit is contained in:
parent
ab655162cb
commit
4ba69753f9
@ -1092,7 +1092,8 @@ bool Socket::isReadable() {
|
||||
}
|
||||
}
|
||||
//return (i == 1 && FD_ISSET(sock, &set));
|
||||
return (i == 1);
|
||||
bool result = (i == 1);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Socket::isWritable(bool waitOnDelayedResponse) {
|
||||
@ -1153,9 +1154,23 @@ bool Socket::isConnected() {
|
||||
if(isReadable()) {
|
||||
char tmp;
|
||||
int err = peek(&tmp, sizeof(tmp));
|
||||
return (err > 0);
|
||||
if(err <= 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
// Need this extra check for proper linux disconnect checking
|
||||
struct sockaddr name;
|
||||
socklen_t namelen = sizeof (name);
|
||||
|
||||
int peer_result = getpeername(sock, &name, &namelen);
|
||||
if(peer_result != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//otherwise the socket is connected
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user