mirror of
https://github.com/glest/glest-source.git
synced 2025-08-17 13:50:43 +02:00
- beter checking for dsiconnected socket for sensitive winsock
This commit is contained in:
@@ -1887,7 +1887,7 @@ NetworkMessageType ClientInterface::waitForMessage(int waitMicroseconds)
|
|||||||
|
|
||||||
msg = getNextMessageType(waitMicroseconds);
|
msg = getNextMessageType(waitMicroseconds);
|
||||||
if(msg == nmtInvalid) {
|
if(msg == nmtInvalid) {
|
||||||
if(chrono.getMillis() % 250 == 0 && isConnected() == false) {
|
if(getSocket() == NULL || (chrono.getMillis() % 250 == 0 && isConnected() == false)) {
|
||||||
if(getQuit() == false) {
|
if(getQuit() == false) {
|
||||||
//throw megaglest_runtime_error("Disconnected");
|
//throw megaglest_runtime_error("Disconnected");
|
||||||
//sendTextMessage("Server has Disconnected.",-1);
|
//sendTextMessage("Server has Disconnected.",-1);
|
||||||
|
@@ -184,6 +184,9 @@ NetworkMessageType NetworkInterface::getNextMessageType(int waitMilliseconds) {
|
|||||||
// if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] PEEK WARNING, socket->getDataToRead() messageType = %d [size = %d], dataSize = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,messageType,sizeof(messageType),dataSize);
|
// if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] PEEK WARNING, socket->getDataToRead() messageType = %d [size = %d], dataSize = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,messageType,sizeof(messageType),dataSize);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
if (socket->isSocketValid() == false) {
|
||||||
|
return nmtInvalid;
|
||||||
|
}
|
||||||
//sanity check new message type
|
//sanity check new message type
|
||||||
if(messageType < 0 || messageType >= nmtCount) {
|
if(messageType < 0 || messageType >= nmtCount) {
|
||||||
if(getConnectHasHandshaked() == true) {
|
if(getConnectHasHandshaked() == true) {
|
||||||
|
@@ -50,7 +50,7 @@ bool NetworkMessage::receive(Socket* socket, void* data, int dataSize, bool tryR
|
|||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] WARNING, dataReceived = %d dataSize = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,dataReceived,dataSize);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] WARNING, dataReceived = %d dataSize = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,dataReceived,dataSize);
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\nIn [%s::%s Line: %d] WARNING, dataReceived = %d dataSize = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,dataReceived,dataSize);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\nIn [%s::%s Line: %d] WARNING, dataReceived = %d dataSize = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,dataReceived,dataSize);
|
||||||
|
|
||||||
if(socket != NULL && socket->getSocketId() > 0) {
|
if(socket != NULL && socket->isSocketValid() == true) {
|
||||||
throw megaglest_runtime_error("Error receiving NetworkMessage, dataReceived = " + intToStr(dataReceived) + ", dataSize = " + intToStr(dataSize));
|
throw megaglest_runtime_error("Error receiving NetworkMessage, dataReceived = " + intToStr(dataReceived) + ", dataSize = " + intToStr(dataSize));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -75,7 +75,7 @@ void NetworkMessage::send(Socket* socket, const void* data, int dataSize) {
|
|||||||
dump_packet("\nOUTGOING PACKET:\n",data, dataSize, true);
|
dump_packet("\nOUTGOING PACKET:\n",data, dataSize, true);
|
||||||
int sendResult = socket->send(data, dataSize);
|
int sendResult = socket->send(data, dataSize);
|
||||||
if(sendResult != dataSize) {
|
if(sendResult != dataSize) {
|
||||||
if(socket != NULL && socket->getSocketId() > 0) {
|
if(socket != NULL && socket->isSocketValid() == true) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
snprintf(szBuf,8096,"Error sending NetworkMessage, sendResult = %d, dataSize = %d",sendResult,dataSize);
|
snprintf(szBuf,8096,"Error sending NetworkMessage, sendResult = %d, dataSize = %d",sendResult,dataSize);
|
||||||
throw megaglest_runtime_error(szBuf);
|
throw megaglest_runtime_error(szBuf);
|
||||||
|
@@ -1819,6 +1819,7 @@ bool Socket::isConnected() {
|
|||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) SystemFlags::OutputDebug(SystemFlags::debugError,"SOCKET DISCONNECTED In [%s::%s Line: %d] ERROR Peek failed, err = %d for socket: %d, error = %s, lastSocketError = %d\n",__FILE__,__FUNCTION__,__LINE__,err,sock,getLastSocketErrorFormattedText().c_str(),lastSocketError);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) SystemFlags::OutputDebug(SystemFlags::debugError,"SOCKET DISCONNECTED In [%s::%s Line: %d] ERROR Peek failed, err = %d for socket: %d, error = %s, lastSocketError = %d\n",__FILE__,__FUNCTION__,__LINE__,err,sock,getLastSocketErrorFormattedText().c_str(),lastSocketError);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (isSocketValid() == false) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//otherwise the socket is connected
|
//otherwise the socket is connected
|
||||||
|
Reference in New Issue
Block a user