3 ms·
I thought this article was going to be about the blocking recv() with a closed socket "issue" in linux, but it wasn't. For those that don't know, linux behaves
by StillBored 12y ago
I thought this article was going to be about the blocking recv() with a closed socket "issue" in linux, but it wasn't.
For those that don't know, linux behaves differently than other unix in that a thread blocked in recv() will remain blocked in recv if another thread closes the underlying socket.
AKA, the article works because GDB is interrupting the recv() call (or the socket was marked nonblocking), not because simply closing a socket wakes up a blocked recv() in linux.
- realusername 12y agoYes exactly, and if I remember correctly (my C language memory is starting to fade these days), there is even a flag to reuse the same socket when the program open again (SO_REUSEADDR ?).