-
Notifications
You must be signed in to change notification settings - Fork 36
Standardise sockets #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… package to call socket.recv with a bufsize.
…. htons is faster with << >>.
…e parameters used in CPython.
…accept IPv4 address as a 4-tuple to match the parameters used in CPython.
…Use __setattr__ to work around accessing a protected item.
…ace because bad things happen.
…n. Removed timeout from socket.__init__. Remove socket._socknum property.
…llow socket.accept to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a few questions about possible tweaks.
I will also test this branch out on a device this week and report back how it goes.
Thank you again for all of the hard work you've put into the improvements for this library @BiffoBear!
@FoamyGuy Please have a look at this too, the function can take either 2 or 3 args and CP does not support overloading, so I don't know how to type this function.
|
Refactored |
I saw that one. I Do think think way you've done it is good. I don't know of any better way that we could type / document it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good to me.
I have tested this version successfully with a Feather ESP32-S2 TFT and Ethernet Featherwing with:
- wiznet5k_simpletest.py
- wiznet5k_simpleserver.py
- wiznet5k_wsgiserver.py
- wiznet5k_aio_post.py
and all are working as expected.
I also checked htonl() against the currently released version to ensure they output the same thing from same input. Lastly I compared inet_aton
and inet_ntoa
outputs to output from the same function from cpython built-in module socket. All are matching as expected.
Thank you again @BiffoBear for working on this and all of the other improvements!
Updating https://github.com/adafruit/Adafruit_CircuitPython_Wiznet5k to 2.0.0 from 1.13.5: > Merge pull request adafruit/Adafruit_CircuitPython_Wiznet5k#87 from BiffoBear/Standardise_Sockets Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA: > Updated download stats for the libraries
Updated
adafruit_wiznet5k_socket.py
to match as closely as possible CPythonsocket
. Functions that exist in Cpythonsocket
have matching parameters and return types. Functions that exist in wiznet5ksocket
but not in Cpythonsocket
were renamed with a leading_
exceptsocket.setinterface
.Main differences:
flags
still not implemented, not planned to be.socket.bind
can only bind to the IP address that the Wiznet chip was initialized with. All the hardware sockets share this single address. Changing the IP address after initialization leaves previously connected sockets in an unknown state. RaisesValueError
if the IP address does not match.socket.bind
should raise an exception if the socket is already bound. Making this check currently causessocket.accept
to fail because it calls 'bind' on a bound socket (now solved).Not attempted, TODO: at a later date:
adafruit_wiznet5k.py
socket
nonstandard functions then remove nonstandard functions.This has been tested by running
simpletest.py
andsimpleserver.py
.More testing would be appreciated.