Is socket.shutdown(1) useless

Mohamed Garrana mgarrana at mantrac.com.eg
Thu Jun 4 21:42:23 CEST 2009


Hello

This is is in answer for Is socket.shutdown(1) useless

Shutdown(1) , forces the socket no to send any more data

This is usefull in

Buffer flushing

Strange error detection

Safe guarding

Let me explain more , when you send a data , it's not guaranteed to be
sent to your peer , it's only guaranteed to be sent to the os buffer ,
which in turn sends it to the peer os buffer

So by doing shutdown(1) , you flush your buffer and an error is raised
if the buffer is not empty ie: data has not been sent to the peer yet

Howoever this is irrevesable , so you can do that after you completely
sent all your data and you want to be sure that it's atleast at the peer
os buffer

 

 

Everything's ok in the end...if it's not ok, then its not the end.

 

P save paper...

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090604/76e22fdd/attachment.html>


More information about the Python-list mailing list