Skip to content

Commit 465c758

Browse files
committed
Optimize listen()
1 parent 6b3484d commit 465c758

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

adafruit_wiznet5k/adafruit_wiznet5k.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -660,13 +660,11 @@ def socket_listen(self, socket_num: int, port: int, conn_mode: int = _SNMR_TCP)
660660
# Send listen command
661661
self._write_sncr(socket_num, _CMD_SOCK_LISTEN)
662662
# Wait until ready
663-
status = SNSR_SOCK_CLOSED
664-
while status not in {
663+
while (status := self._read_snsr(socket_num)) not in {
665664
SNSR_SOCK_LISTEN,
666665
SNSR_SOCK_ESTABLISHED,
667666
_SNSR_SOCK_UDP,
668667
}:
669-
status = self._read_snsr(socket_num)
670668
if status == SNSR_SOCK_CLOSED:
671669
raise RuntimeError("Listening socket closed.")
672670

0 commit comments

Comments
 (0)