Python doesn't detect a closed socket until the second send

前端 未结 2 1592
一个人的身影
一个人的身影 2020-12-31 04:26

When I close the socket on one end of a connection, the other end gets an error the second time it sends data, but not the first time:

import socket

server          


        
2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-31 05:01

    As per the docs, try calling sock.shutdown() before the call to sock.close().

提交回复
热议问题