Skip to content

Add socket.IP_FREEBIND constant #132991

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

Closed
alyssais opened this issue Apr 26, 2025 · 4 comments
Closed

Add socket.IP_FREEBIND constant #132991

alyssais opened this issue Apr 26, 2025 · 4 comments
Labels
extension-modules C modules in the Modules dir type-feature A feature request or enhancement

Comments

@alyssais
Copy link
Contributor

alyssais commented Apr 26, 2025

Feature or enhancement

Proposal:

The socket options exposed by CPython's socket module do not include IP_FREEBIND, meaning the option number has to be hardcoded. Examples of this in the wild can be find using GitHub's code search.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

@alyssais alyssais added the type-feature A feature request or enhancement label Apr 26, 2025
@picnixz picnixz added the extension-modules C modules in the Modules dir label Apr 26, 2025
@picnixz picnixz changed the title socket.IP_FREEBIND Add socket.IP_FREEBIND constant Apr 26, 2025
@picnixz
Copy link
Member

picnixz commented Apr 26, 2025

Examples of this in the wild can be find using GitHub's code search.

What kind of code search did you do for that? could you share your findings? (I don't mind adding this constant if it's that useful though so TiA)

@alyssais
Copy link
Contributor Author

https://github.com/search?q=setsockopt+IP_FREEBIND+15+language%3APython&type=code

You can see lots of different approaches to work around the lack of this constant.

I'll make a PR shortly.

alyssais added a commit to alyssais/cpython that referenced this issue Apr 26, 2025
alyssais added a commit to alyssais/cpython that referenced this issue Apr 26, 2025
@picnixz
Copy link
Member

picnixz commented Apr 26, 2025

Thanks. Is there something we however need to do in particular with this constant? should we handle it specifically in some contexts? (I don't know)

@alyssais
Copy link
Contributor Author

No, it's just for passing to setsockopt().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension-modules C modules in the Modules dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants