Skip to content

Commit

Permalink
Merge pull request #201 from adafruit/connect_dgram_mode
Browse files Browse the repository at this point in the history
socket.connect(): Auto-select UDP_MODE
  • Loading branch information
FoamyGuy committed May 6, 2024
2 parents 69b6e97 + 86ffa6b commit 56864ac
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions adafruit_esp32spi/adafruit_esp32spi_socketpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ def connect(self, address, conntype=None):
depending on the underlying interface"""
host, port = address
if conntype is None:
conntype = self._interface.TCP_MODE
conntype = (
self._interface.UDP_MODE
if self._type == SocketPool.SOCK_DGRAM
else self._interface.TCP_MODE
)
if not self._interface.socket_connect(
self._socknum, host, port, conn_mode=conntype
):
Expand All @@ -117,7 +121,7 @@ def connect(self, address, conntype=None):

def send(self, data):
"""Send some data to the socket."""
if self._type is SocketPool.SOCK_DGRAM:
if self._type == SocketPool.SOCK_DGRAM:
conntype = self._interface.UDP_MODE
else:
conntype = self._interface.TCP_MODE
Expand Down

0 comments on commit 56864ac

Please sign in to comment.