Reputation: 7482
I am writing a small networking program where latency is very important. I would like to catch all possible cases where execution is blocked in some system call.
I know that connect
can block execution for several seconds. read
blocks until data is available. write
blocks until there is enough of space in system buffers. The question is: can close
block execution for some time? If yes, is this solved by using non-blocking sockets?
I am working on Linux. However, it is interesting to learn about other systems as well.
Upvotes: 2
Views: 585
Reputation: 322
Yes close can block. It happens when there is another thread blocked on recv/send call on same socket.
Use non-blocking sockets to avoid this.
Upvotes: 2