This actually should work fine (at least the socket portion)... the crashing may be due to something else related to synchronicity of the threads.
One thing is for sure though, on a blocking socket, closing the socket WILL always return from the recv() call (at least in Windows, Wine implementations don't do this, but if you're Windows only, it shouldn't be a problem).
From the recv() description from MSDN:
Quote:
If the socket is connection oriented and the remote side has shut down the connection gracefully, and all data has been received, a recv will complete immediately with zero bytes received. If the connection has been reset, a recv will fail with the error WSAECONNRESET.