Skip to content

Commit c47cd07

Browse files
author
BiffoBear
committed
Disabled checking whether socket is already bound in socket.bind to allow socket.accept to work.
1 parent 05062e6 commit c47cd07

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

adafruit_wiznet5k/adafruit_wiznet5k_socket.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,18 +289,20 @@ def getpeername(self) -> Tuple[str, int]:
289289
)
290290

291291
def bind(self, address: Tuple[Optional[str], int]) -> None:
292-
"""Bind the socket to address. The socket must not already be bound.
292+
"""
293+
Bind the socket to address. The socket must not already be bound.
293294
294-
The hardware sockets on WIZNET5K systems all share the same IPv4 address that
295-
was assigned at startup. Ports can only be bound to this address.
295+
The hardware sockets on WIZNET5K systems all share the same IPv4 address. The
296+
address is assigned at startup. Ports can only be bound to this address.
296297
297298
:param Tuple[Optional[str], int] address: Address as a (host, port) tuple.
298299
299300
:raises ValueError: If the IPv4 address specified is not the address
300301
assigned to the WIZNET5K interface.
301302
"""
302-
if self._listen_port:
303-
raise ConnectionError("The socket is already bound.")
303+
# Check is disabled to allow socket.accept to swap sockets.
304+
# if self._listen_port:
305+
# raise ConnectionError("The socket is already bound.")
304306
if address[0]:
305307
if gethostbyname(address[0]) != _the_interface.pretty_ip(
306308
_the_interface.ip_address

examples/wiznet5k_simpleserver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
spi_bus = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
1919

2020
# Initialize ethernet interface
21-
eth = WIZNET5K(spi_bus, cs, is_dhcp=False)
21+
eth = WIZNET5K(spi_bus, cs, is_dhcp=True)
2222

2323
# Initialize a socket for our server
2424
socket.set_interface(eth)

0 commit comments

Comments
 (0)