Skip to content

Commit f78907e

Browse files
authored
Merge pull request #151 from pinkavaj/pi-fix-recv
Fix hangup on reading of closed socket
2 parents 9fd20cf + 89b9f10 commit f78907e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

adafruit_wiznet5k/adafruit_wiznet5k_socket.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,12 @@ def recv_into(self, buffer: bytearray, nbytes: int = 0, flags: int = 0) -> int:
614614
elif num_read > 0:
615615
# We got a message, but there are no more bytes to read, so we can stop.
616616
break
617+
elif self._status in (
618+
wiznet5k.adafruit_wiznet5k.SNSR_SOCK_CLOSED,
619+
wiznet5k.adafruit_wiznet5k.SNSR_SOCK_CLOSE_WAIT,
620+
):
621+
# No bytes to read and we will not get more, stop.
622+
break
617623
# No bytes yet, or more bytes requested.
618624
if self._timeout is None:
619625
# blocking mode

0 commit comments

Comments
 (0)