-
Notifications
You must be signed in to change notification settings - Fork 1.3k
raspberrypi: implement setsockopt(SOL_SOCKET, SO_REUSEADDR) #9084
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
...works fine, no exceptions. A number of resets of the server didn't yield any exceptions. We can test the no-reuse case pending the question above. I'm not sure how to reliably trigger the address in use exception though (that may become apparent by clearing SOF_REUSEADDR). |
With today's artifact and same latest release of the adafruit_httpserver library, I get if implementation.version >= (9,) or implementation.name != "circuitpython":
sock.setsockopt(socket_source.SOL_SOCKET, socket_source.SO_REUSEADDR, 1) But if I change it to (btw, I'm using |
memcmp() returns -1, 0 or 1 to denote the relative ordering of the two buffers. So, the computation would actually set `enable = 0` in the case where `value` had the same bits set as "one" and `enable = 1` in the case where `value` had any other bits. By changing the compared buffer to be `zero`, `enable` gets a true value whenever the value is NOT exactly 0 (e.g., it's 1, 7, -1, ...), correcting the sense of enable vs disable. Thanks to @anecdata for testing and finding this problem, which previously would have affected the nodelay flag as well.
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.
.SO_REUSEADDR, 1
now prevents EADDRINUSE
and allows the server to immediately re-bind, and .SO_REUSEADDR, 0
raises EADDRINUSE
when attempting to re-bind within the timeout. Thanks, @jepler !
really appreciated the testing @anecdata ! |
untested
edit by @dhalbert:
Fixes #9081.