When to not just use socket.close()


Version: 1.4
Category:
Scripts
Python
Requirements:
Seller:
Price:
-
System:
Rating:
4.5
License:

Description - When to not just use socket.close()



The close operation is not Atomic. It implicitly tries to send any remaining data in _addition_ to closing a descriptor. Splitting this close operation up with the aid of the Shutdown Command can help avoid bugs. It gives the server one final way to say, "something went wrong". The server would also know that the client did not end correctly, since the socket should remain open when the client finished sending data. For example, if the function exits unexpectedly and Python closes the socket for you, the server would not be able to send any data back. In the server below, the client and server have different ideas about what the end marker should be. The rev_end function is written so as to look for an end marker. And, as long as they agree it should work. The socket.shutdown is for when something goes wrong.



More in Python-When to not just use socket.close()

Function Marker Server Would Function Exits Unexpectedly