Yohai
Yohai

Reputation: 19

How can you detect a socket has been closed while waiting on recv?

how can I detect that a socket I am currently listening at with recv() has been closed?

Upvotes: 1

Views: 900

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 596713

socket.recv() will return an empty byte array if the peer has closed the connection gracefully. Otherwise it will raise an error.

Upvotes: 1

Related Questions