Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix socket accept flow and timeout code #153

Merged
merged 2 commits into from
Apr 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion adafruit_wiznet5k/adafruit_wiznet5k_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import gc
import time
from sys import byteorder
from errno import ETIMEDOUT

from micropython import const

Expand Down Expand Up @@ -400,6 +401,7 @@ def accept(
while self._status not in (
wiznet5k.adafruit_wiznet5k.SNSR_SOCK_SYNRECV,
wiznet5k.adafruit_wiznet5k.SNSR_SOCK_ESTABLISHED,
wiznet5k.adafruit_wiznet5k.SNSR_SOCK_LISTEN,
):
if self._timeout and 0 < self._timeout < time.monotonic() - stamp:
raise TimeoutError("Failed to accept connection.")
Expand Down Expand Up @@ -772,7 +774,7 @@ class timeout(TimeoutError):
the timeout has elapsed and we haven't received any data yet."""

def __init__(self, msg):
super().__init__(msg)
super().__init__(ETIMEDOUT, msg)


# pylint: enable=unused-argument, redefined-builtin, invalid-name
Loading