adafruit / Adafruit_CircuitPython_ESP32SPI

ESP32 as wifi with SPI interface
MIT License
103 stars 75 forks source link

UDP Client using socket #127

Closed anecdata closed 3 years ago

anecdata commented 3 years ago

UDP Client was previously possible using esp calls directly. This change allows UDP Client at the socket level.

anecdata commented 3 years ago

@brentru Do you see any issues with adding the kwarg to socket.send()?

brentru commented 3 years ago

I do have an issue with this PR - the socket class should match CPython Socket send (https://docs.python.org/3.8/library/socket.html#socket.socket.send) and SocketPool's socket send (https://circuitpython.readthedocs.io/en/latest/shared-bindings/socketpool/index.html#socketpool.Socket.send).

Instead, like CPython, within the init's type kwarg, could you pass SOCK_DGRAM from the code initializing the socket, instead of SOCK_STREAM to make the socket a UDP type? The conntype kwarg wouldn't be added to send since you could add a new private type attribute to the socket.

anecdata commented 3 years ago

I can look in to that. I mirrored the way connect uses the kwarg (even though there is no "connect" with UDP, the call is needed - NINA, and the Arduino WiFi structures it's written around are very un-CPython-like.).

anecdata commented 3 years ago

Re-tested with (modified) UDP client. Regression tested with TCP client and HTTP client (Requests).