Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While porting code from a WiFi-based board (Pico 2 W) to a wired ethernet board (WIZnet W5500-EVB-Pico2) I ran into problems caused by differences in behaviour between CircuitPython core sockets and those provided by this driver. This pull request aims to correct three discrepancies with modifications to
adafruit_wiznet5k_socketpool.py
:recv_into()
now raisesOSError(errno.EAGAIN)
when the socket is in non-blocking mode and nothing is received.Instead of always returning instantly with
addr = ("0.0.0.0", 0)
,accept()
now respects the specified socket mode, i.e.:OSError(errno.ETIMEDOUT)
is raised when the timeout expires.OSError(errno.EAGAIN)
is raised if there is no connection to accept.This has the added benefit of avoiding the overhead of the WIZnet socket swap dance until an actual connection is established.
close()
now calls_disconnect
onSOCK_STREAM
sockets. I'm not 100% sure on this one, but I noticed while comparing functionally equivalent code between Pico WiFi and WIZnet wired using PuTTy, callingclose()
on the Pico correctly closed my PuTTy session, but callingclose()
on the WIZnet just left my PuTTy session hanging. Adding the_disconnect()
call inclose()
made the behaviour between the two match.For testing 1 and 2 I used the script available here. While testing
accept()
I used a modified version of @niclas-gr's script from #170 available here.This pull request resolves the issues (that I am aware of) that I reported in #177, and I believe it resolves #170 as well. The
wiznet5k_simpletest.py
,wiznet5k_httpserver.py
andwiznet5k_aio_post.py
examples all ran correctly with these changes in place. (Side note: theapi.coindesk.com
URL insimpletest
appears to no longer be valid.)