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 Feb 28, 2024
1 parent 3bd953e commit 8553558
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions adafruit_wiznet5k/adafruit_wiznet5k_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,11 @@ def inet_ntoa(ip_address: Union[bytes, bytearray]) -> str:
raise ValueError("The IPv4 address must be 4 bytes.")
return _the_interface.pretty_ip(ip_address)

SOCK_STREAM = 1
SOCK_DGRAM = 2

circuitpython_type_to_wiznet_type = b'\0\x21\2'

SOCK_STREAM = const(0x21) # TCP
_TCP_MODE = 80
SOCK_DGRAM = const(0x02) # UDP
AF_INET = const(3)
_SOCKET_INVALID = const(255)

Expand Down Expand Up @@ -431,7 +432,7 @@ def connect(self, address: Tuple[str, int]) -> None:
self._socknum,
_the_interface.unpretty_ip(gethostbyname(address[0])),
address[1],
self._sock_type,
circuitpython_type_to_wiznet_type[self._sock_type],
)
_the_interface.src_port = 0
if not result:
Expand Down Expand Up @@ -674,7 +675,7 @@ 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, circuitpython_type_to_wiznet_type[self._sock_type])

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

0 comments on commit 8553558

Please sign in to comment.