mirror of
https://github.com/glest/glest-source.git
synced 2025-08-16 13:23:59 +02:00
- added extra check on linux for socket disconnect
This commit is contained in:
@@ -1092,7 +1092,8 @@ bool Socket::isReadable() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//return (i == 1 && FD_ISSET(sock, &set));
|
//return (i == 1 && FD_ISSET(sock, &set));
|
||||||
return (i == 1);
|
bool result = (i == 1);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Socket::isWritable(bool waitOnDelayedResponse) {
|
bool Socket::isWritable(bool waitOnDelayedResponse) {
|
||||||
@@ -1153,9 +1154,23 @@ bool Socket::isConnected() {
|
|||||||
if(isReadable()) {
|
if(isReadable()) {
|
||||||
char tmp;
|
char tmp;
|
||||||
int err = peek(&tmp, sizeof(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
|
//otherwise the socket is connected
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user