i am currently trying to go through a basic tutorial on networking and i noticed that a rudimentary client/server program would freeze upon the server trying to read more data from the client when all the data is received . Basically the code looks like this :
if not more :
raise EOFError('socket inchis %d octeti intr-un mesaj de %d octeti'%(len(data),length))
As others have pointed out, the cause is the fact that sockets are blocking by default. It means that the
recv function will block the execution of the program until some data arrive. Unless things are changed, the program will wait forever, or until the server breaks the connection.
One solution is to switch to non-blocking sockets, using the
settimeout function, like this
sock.settimeout(2). This means that if nothing is received within 2 seconds, an exception will be thrown. You can catch that exception and handle it accordingly.