From 1dbdc29622c17641292265bbc08be1d705491809 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Sun, 29 May 2011 23:01:16 +0000 Subject: [PATCH] - do not throw error when connection drops on partial socket receive, just log the condition and close gracefully --- source/shared_lib/sources/platform/posix/socket.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/source/shared_lib/sources/platform/posix/socket.cpp b/source/shared_lib/sources/platform/posix/socket.cpp index d5181f42c..23f1e3e76 100644 --- a/source/shared_lib/sources/platform/posix/socket.cpp +++ b/source/shared_lib/sources/platform/posix/socket.cpp @@ -1276,7 +1276,15 @@ int Socket::receive(void *data, int dataSize, bool tryReceiveUntilDataSizeMet) { bytesReceived += additionalBytes; } else { - throw runtime_error("additionalBytes == " + intToStr(additionalBytes)); + //throw runtime_error("additionalBytes == " + intToStr(additionalBytes)); + if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] additionalBytes == %d\n",__FILE__,__FUNCTION__,__LINE__,additionalBytes); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\nIn [%s::%s Line: %d] additionalBytes == %d\n",__FILE__,__FUNCTION__,__LINE__,additionalBytes); + if(SystemFlags::getSystemSettingType(SystemFlags::debugError).enabled) SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] additionalBytes == %d\n",__FILE__,__FUNCTION__,__LINE__,additionalBytes); + + int iErr = getLastSocketError(); + disconnectSocket(); + + if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s Line: %d] DISCONNECTED SOCKET error while receiving socket data, bytesReceived = %d, error = %s, dataSize = %d, tryReceiveUntilDataSizeMet = %d\n",__FILE__,__FUNCTION__,__LINE__,bytesReceived,getLastSocketErrorFormattedText(&iErr).c_str(),dataSize,tryReceiveUntilDataSizeMet); } } return static_cast(bytesReceived);