Reputation: 1252
I am using the socket library to emulate sending packets over the network.
Documentation for socket.settimeout() method says..
... socket.settimeout(value) Set a timeout on blocking socket operations. The value argument can be a nonnegative float expressing seconds, or None. If a float is given, subsequent socket operations will raise a timeout exception if the timeout period value has elapsed before the operation has completed. Setting a timeout of None disables timeouts on socket operations. s.settimeout(0.0) is equivalent to s.setblocking(0); s.settimeout(None) is equivalent to s.setblocking(1).
What exactly are the blocking socket operations? Is it just recv* calls, or does it also include send calls?
Thank you in advance.
Upvotes: 1
Views: 862
Reputation: 123405
Blocking operations are operations which can not fully handled locally but where it might need to wait for the peer of the connection. For TCP sockets this includes therefore obviously accept, connect and recv. But it also includes send: send might block if the local write socket buffer is full, i.e. no more data can be written to it. In this case it must wait for the peer to receive and acknowledge enough data so that these data get removed from the write buffer and there is again room to write new data.
Upvotes: 1