tags:

views:

44

answers:

1

I have a blocking call to accept(). From another thread I close the socket, hoping that it'll unblock the accept() call, which it does but I have a case when it doesn't: e.g. thread A enters accept(), thread B closes the socket, thread A doesn't return from accept().

Question: what could cause closing a socket to not unblock an accept()?

A: 

Try calling shutdown() followed by close() from thread B. You should be checking the return codes on these calls too as they may help you figure out what is going wrong when thread A fails to become unblocked.

Arnold Spence
Calling shutdown() doesn't help (not surprisingly, if called, it returns WSAENOTCONN). Calling closesocket(), with or without having called shutdown(), succeeds. I've verified that the handle being closed is the same one that hangs in the accept() call. No luck.
Emil