- change to properly toggle socket blocking mode in Linux

This commit is contained in:
Mark Vejvoda
2010-11-09 16:51:03 +00:00
parent d89953ee96
commit d2de4eb22a

View File

@@ -1164,7 +1164,14 @@ void Socket::setBlock(bool block){
void Socket::setBlock(bool block, PLATFORM_SOCKET socket){
#ifndef WIN32
int err= fcntl(socket, F_SETFL, block ? 0 : O_NONBLOCK);
int currentFlags = fcntl(socket, F_GETFL);
if(block == true) {
currentFlags |= O_NONBLOCK;
}
else {
currentFlags &= (~O_NONBLOCK);
}
int err= fcntl(socket, F_SETFL, currentFlags);
#else
u_long iMode= !block;
int err= ioctlsocket(socket, FIONBIO, &iMode);