Skip to content

Commit

Permalink
Merge pull request #151 from pinkavaj/pi-fix-recv
Browse files Browse the repository at this point in the history
Fix hangup on reading of closed socket
  • Loading branch information
FoamyGuy authored Apr 22, 2024
2 parents 9fd20cf + 89b9f10 commit f78907e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions adafruit_wiznet5k/adafruit_wiznet5k_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,12 @@ def recv_into(self, buffer: bytearray, nbytes: int = 0, flags: int = 0) -> int:
elif num_read > 0:
# We got a message, but there are no more bytes to read, so we can stop.
break
elif self._status in (
wiznet5k.adafruit_wiznet5k.SNSR_SOCK_CLOSED,
wiznet5k.adafruit_wiznet5k.SNSR_SOCK_CLOSE_WAIT,
):
# No bytes to read and we will not get more, stop.
break
# No bytes yet, or more bytes requested.
if self._timeout is None:
# blocking mode
Expand Down

0 comments on commit f78907e

Please sign in to comment.