Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Moved call of socket_listen with SNMR_UDP to adafruit_wiznet5k_socket…
….bind()
  • Loading branch information
obaltzer committed Jul 21, 2021
commit 8fe0de857103ec66f59d73febdb58200c9fb6096
5 changes: 1 addition & 4 deletions adafruit_wiznet5k/adafruit_wiznet5k.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ def get_socket(self):
return sock

def socket_listen(self, socket_num, port, conn_mode=SNMR_TCP):
"""Start listening on a socket (TCP mode only).
"""Start listening on a socket (default TCP mode).
:parm int socket_num: socket number
:parm int port: port to listen on
"""
Expand All @@ -580,9 +580,6 @@ def socket_listen(self, socket_num, port, conn_mode=SNMR_TCP):
if status[0] == SNSR_SOCK_CLOSED:
raise RuntimeError("Listening socket closed.")

def socket_listen_udp(self, socket_num, port):
self.socket_listen(socket_num, port, SNMR_UDP)

def socket_accept(self, socket_num):
"""Gets the dest IP and port from an incoming connection.
Returns the next socket number so listening can continue
Expand Down
6 changes: 4 additions & 2 deletions adafruit_wiznet5k/adafruit_wiznet5k_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,12 @@ def bind(self, address):
if ip_address != current_ip:
_the_interface.ifconfig = (ip_address, subnet_mask, gw_addr, dns)
self._listen_port = address[1]
# For UDP servers we need to open the socket here because we won't call
# For UDP servers we need to open the socket here because we won't call
# listen
if self._sock_type == SOCK_DGRAM:
_the_interface.socket_listen_udp(self.socknum, self._listen_port)
_the_interface.socket_listen(
self.socknum, self._listen_port, wiznet5k.adafruit_wiznet5k.SNMR_UDP
)
self._buffer = b""

def listen(self, backlog=None):
Expand Down