Skip to content

Commit

Permalink
Use SOCK_STREAM & SOCK_DGRAM numbers that match circuitpython core
Browse files Browse the repository at this point in the history
A future enhancement to the core ssl module might require this
  • Loading branch information
jepler committed Apr 17, 2024
1 parent 3bd953e commit 20d503d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions adafruit_wiznet5k/adafruit_wiznet5k_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,11 @@ def inet_ntoa(ip_address: Union[bytes, bytearray]) -> str:
return _the_interface.pretty_ip(ip_address)


SOCK_STREAM = const(0x21) # TCP
_TCP_MODE = 80
SOCK_DGRAM = const(0x02) # UDP
SOCK_STREAM = 1
SOCK_DGRAM = 2

_SOCKET_TYPE_TO_WIZNET = b"\0\x21\2"

AF_INET = const(3)
_SOCKET_INVALID = const(255)

Expand Down Expand Up @@ -431,7 +433,7 @@ def connect(self, address: Tuple[str, int]) -> None:
self._socknum,
_the_interface.unpretty_ip(gethostbyname(address[0])),
address[1],
self._sock_type,
_SOCKET_TYPE_TO_WIZNET[self._sock_type],
)
_the_interface.src_port = 0
if not result:
Expand Down Expand Up @@ -674,7 +676,9 @@ def _available(self) -> int:
:return int: Number of bytes available.
"""
return _the_interface.socket_available(self._socknum, self._sock_type)
return _the_interface.socket_available(
self._socknum, _SOCKET_TYPE_TO_WIZNET[self._sock_type]
)

@_check_socket_closed
def settimeout(self, value: Optional[float]) -> None:
Expand Down

0 comments on commit 20d503d

Please sign in to comment.