Fixes for error handling in NetChannel
- return the correct errno value instead of using -1
This commit is contained in:
@@ -684,6 +684,15 @@ bool Socket::isNonBlockingError ()
|
||||
#endif
|
||||
}
|
||||
|
||||
int Socket::errorNumber()
|
||||
{
|
||||
#if defined(WINSOCK)
|
||||
return WSAGetLastError();
|
||||
#else
|
||||
return errno;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
@@ -101,7 +101,8 @@ public:
|
||||
void setBroadcast ( bool broadcast ) ;
|
||||
|
||||
static bool isNonBlockingError () ;
|
||||
|
||||
static int errorNumber();
|
||||
|
||||
static int select ( Socket** reads, Socket** writes, int timeout ) ;
|
||||
} ;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user