8000 Improve how non-core socket implementations get their value of SOCK_STREAM. · Issue #10072 · adafruit/circuitpython · GitHub
[go: up one dir, main page]

Skip to content
8000

Improve how non-core socket implementations get their value of SOCK_STREAM. #10072

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

Open
jepler opened this issue Feb 16, 2025 · 0 comments
Open

Comments

@jepler
Copy link
jepler commented Feb 16, 2025

Recently in Discord, @tannewt encountered that zephyr uses different numeric values for some socket-related constants (vs lwip)

For core ssl support to work with pure Python socket implementations, such as wiznet, we had to promise that socket constants used by the ssl implementation would be the same numeric constants always, regardless of the internal implementation of sockets.

I think that the sole constant we depend on is is SOCK_STREAM = 1. This is because SSL can work on STREAM type sockets but not DGRAM type sockets.

@tannewt suggested that instead of the current approach of promising SOCK_STREAM = 1 (the lwip value, used by raspberrypi & espressif), anytime we enable ssl in the core we could provide a minimal socket library with SOCK_STREAM = (some value), not necessarily 1.

Then, wiznet would have to do something like

try:
    from socket import SOCK_STREAM
except ImportError:
    SOCK_STREAM = 1
SOCK_DGRAM = SOCK_STREAM + 1

wiznet currently has to adapt to different SOCK_ type numbering anyway, because wiznet uses 0x21 for SOCK_STREAM. (though it does so in a somewhat clever way that assumes the current values of 1 & 2)

Marking as a 10.0 milestone because undoing the promise that SOCK_STREAM=1 is an incompatible change.

@jepler jepler added this to the 10.0.0 milestone Feb 16, 2025
@dhalbert dhalbert modified the milestones: 10.0.0, 10.x.x May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
0