- added more bug fixes related to network disconnects.

- Added a new global message box to display error messages on top of any graphics window being displayed.
This commit is contained in:
Mark Vejvoda
2010-07-08 08:29:51 +00:00
parent ff21d26161
commit ab655162cb
18 changed files with 275 additions and 127 deletions

View File

@@ -937,8 +937,14 @@ int Socket::getDataToRead(){
int Socket::send(const void *data, int dataSize) {
ssize_t bytesSent= 0;
if(isSocketValid() == true) {
errno = 0;
bytesSent = ::send(sock, reinterpret_cast<const char*>(data), dataSize, 0);
}
// TEST errors
//bytesSent = -1;
// END TEST
if(bytesSent < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN) {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] ERROR WRITING SOCKET DATA, err = %d error = %s\n",__FILE__,__FUNCTION__,__LINE__,bytesSent,getLastSocketErrorFormattedText().c_str());
//throwException(szBuf);
@@ -946,16 +952,25 @@ int Socket::send(const void *data, int dataSize) {
else if(bytesSent < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #1 EAGAIN during send, trying again...\n",__FILE__,__FUNCTION__,__LINE__);
int attemptCount = 0;
time_t tStartTimer = time(NULL);
while((bytesSent < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) && (difftime(time(NULL),tStartTimer) <= 5)) {
attemptCount++;
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d\n",__FILE__,__FUNCTION__,__LINE__,attemptCount);
if(Socket::isWritable(true) == true) {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d, sock = %d, dataSize = %d, data = %p\n",__FILE__,__FUNCTION__,__LINE__,attemptCount,sock,dataSize,data);
bytesSent = ::send(sock, reinterpret_cast<const char*>(data), dataSize, 0);
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] #2 EAGAIN during send, trying again returned: %d\n",__FILE__,__FUNCTION__,bytesSent);
}
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d\n",__FILE__,__FUNCTION__,__LINE__,attemptCount);
}
}
if(bytesSent <= 0) {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] ERROR WRITING SOCKET DATA, err = %d error = %s\n",__FILE__,__FUNCTION__,__LINE__,bytesSent,getLastSocketErrorFormattedText().c_str());
int iErr = getLastSocketError();
disconnectSocket();