Skip to content

Socket behaviour differs from core sockets #177

Open
@fasteddy516

Description

@fasteddy516

I was trying to get the httpserver_websocket.py example from adafruit_httpserver working with a wired WIZnet5K connection and ran into a couple of issues:

  1. The handle_http_requests() task was slow compared to the same code using the builtin wifi on a Pico 2 W.

  2. The handle_websocket_requests() task failed with an IndexError exception immediately after the websocket connection was established.
     
    I created a test script (available here) that will use the W5K driver if it is available or the builtin WiFi in CircuitPython if it isn't, ran it on a Pico 2 W and a WIZnet W5500-EVB-Pico2 and compared the results. It looks like the non-blocking behaviour defined in adafruit_wiznet5k_socketpool differs from the core socketpool module. adafruit_httpserver expects non-blocking sockets to raise OSError(errno.EAGAIN) when there is nothing to process but the W5K driver returns 0 from recv_into() and ("0.0.0.0", 0) from accept().

I made some quick changes to make the behaviour match, and it seems to make everything work correctly. I can create a pull request, but wasn't sure what other testing should be done to ensure there aren't other unintentional side-effects of the changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions