As far as I know, when you call socket.settimeout(value)
and you set a float value greater than 0.0, that socket will raise a scocket.timeout when a call to, fo
The timeout applies to each call to recv().
A) simply use your existing timeout and call recv(to_receive) - I.e. Try to receive all the data in one recv call - in fact I don't see why you shouldn't use this as the default way it works
B) No nothing bad could happen, but any other code which uses that socket needs to be aware of handling timeout.
On your existing code, shouldn't the recv() call be recv(max(4096,to_receive-received)) - that way you won't unintentionally consume any data which follows after the to_receive bytes.