Fixes for error handling in NetChannel

- return the correct errno value instead of using -1
This commit is contained in:
James Turner 2016-03-01 12:34:56 +00:00
parent 43dacf5951
commit b8d07cc460
3 changed files with 14 additions and 4 deletions

View File

@ -684,6 +684,15 @@ bool Socket::isNonBlockingError ()
#endif
}
int Socket::errorNumber()
{
#if defined(WINSOCK)
return WSAGetLastError();
#else
return errno;
#endif
}
//////////////////////////////////////////////////////////////////////
//

View File

@ -101,7 +101,8 @@ public:
void setBroadcast ( bool broadcast ) ;
static bool isNonBlockingError () ;
static int errorNumber();
static int select ( Socket** reads, Socket** writes, int timeout ) ;
} ;

View File

@ -114,7 +114,7 @@ NetChannel::send (const void * buffer, int size, int flags)
write_blocked = true ;
return 0;
} else {
this->handleError (result);
this->handleError (errorNumber());
close();
return -1;
}
@ -134,7 +134,7 @@ NetChannel::recv (void * buffer, int size, int flags)
} else if (isNonBlockingError ()) {
return 0;
} else {
this->handleError (result);
this->handleError (errorNumber());
close();
return -1;
}
@ -207,7 +207,7 @@ NetChannel::handleResolve()
return 0;
} else {
// some other error condition
handleError (result);
handleError (errorNumber());
close();
return -1;
}