Poss开发者_JS百科ible Duplicate:
In Win32, is there a way to test if a socket is non-blocking?
This is how I set socket to non-blocking mode in windows.
unsigned long mode = is_blocking ? 0 : 1; int ret = ::ioctlsocket(m_Socket, FIONBIO, &mode);In my complex library I'm getting occasional locks because some sockets passed to it weren't set to non-blocking mode. So, I would like to add and assert to be able to see where non-blocking socket is passed from. The problem is that I have no idea how to test if socket is blocking or not. On unix, it's simple:
long arg = 0; if((arg = fcntl(m_Socket, F_GETFL, NULL)) < 0) { return ERROR; } bool was_blocking = (arg & O_NONBLOCK) != 0;so, how can I test if socket is blocking on windows.
thanks
Windows does not offer any way to query whether a socket is currently set to blocking or non-blocking.
精彩评论