How to check client shutdown?

MRAB python at mrabarnett.plus.com
Mon Aug 26 16:20:20 EDT 2013


On 26/08/2013 20:45, Paul Pittlerson wrote:
> I'm currently learning about the socket module. My question is how
> can I detect if a connection is closed from the other side, for
> example a KeyboardInterrupt as I frequently use. My code below:
>
[snip]
When reading from a socket, it'll return as much data as is available,
up to the given limit if specified.

If _no_ data is available, then it'll block, unless the socket has been
closed at the other end, in which case it'll return zero bytes (an
empty bytestring).



More information about the Python-list mailing list