5

Possible 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

Community
  • 1
  • 1
Pavel P
  • 15,789
  • 11
  • 79
  • 128

1 Answers1

6

Windows does not offer any way to query whether a socket is currently set to blocking or non-blocking.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • Thanks for the answer, that's exactly what was my conclusion, hard to believe that all their extras with WSAIoctl on top of plain bsd sockets don't list something that is actually can be useful. – Pavel P Nov 29 '10 at 18:55