I'm writing small socket problem and I met a problem with unblocking sockets.
I use this function to unblock socket.
If I try to set socket unblocked after creating socket, connection to server fails with error "ERROR connecting: Operation now in progress". And if I try to set socket unblocked before reading, program fails with error "ERROR on reading: Resource temporarily unavailable".
void set_nonblock(int& socket)
flags = fcntl(socket,F_GETFL,0);
assert(flags != -1);
flags |= O_NONBLOCK;