Skip to content
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

Supply dual-stack (IPv4/IPv6) socket bind routine #69853

Open
jaraco opened this issue Nov 19, 2015 · 6 comments
Open

Supply dual-stack (IPv4/IPv6) socket bind routine #69853

jaraco opened this issue Nov 19, 2015 · 6 comments
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@jaraco
Copy link
Member

jaraco commented Nov 19, 2015

BPO 25667
Nosy @gpshead, @jaraco, @pitrou, @bitdancer, @jleedev
PRs
  • bpo-38907: In http.server script, restore binding to IPv4 on Windows. #17851
  • Superseder
  • bpo-17561: Add socket.bind_socket() convenience function
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2015-11-19.13:32:53.803>
    labels = ['3.7', 'type-feature', 'library']
    title = 'Supply dual-stack (IPv4/IPv6) socket bind routine'
    updated_at = <Date 2020-01-06.02:11:41.244>
    user = 'https://github.com/jaraco'

    bugs.python.org fields:

    activity = <Date 2020-01-06.02:11:41.244>
    actor = 'jaraco'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2015-11-19.13:32:53.803>
    creator = 'jaraco'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 25667
    keywords = ['patch']
    message_count = 5.0
    messages = ['254895', '254900', '261317', '286354', '331942']
    nosy_count = 5.0
    nosy_names = ['gregory.p.smith', 'jaraco', 'pitrou', 'r.david.murray', 'jleedev']
    pr_nums = ['17851']
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'patch review'
    status = 'open'
    superseder = '17561'
    type = 'enhancement'
    url = 'https://bugs.python.org/issue25667'
    versions = ['Python 3.7']

    @jaraco
    Copy link
    Member Author

    jaraco commented Nov 19, 2015

    When binding to a socket for creating a service, the socket API provides a mechanism for selecting only IPv4 or IPv6, but the simple operation of binding to all interfaces in a dual-stack environment is not easy, as is revealed in bpo-20215 and bpo-24209, but also in third-party packages. I ran into this during the implementation of aiosmtpd (https://gitlab.com/python-smtpd-hackers/aiosmtpd). As a long time maintainer of CherryPy, I've enjoyed the dual stack support there.

    I propose the Python stdlib provide a routine to facilitate this need more generally, and then invoke that implementation to address these other use-cases.

    As it is a new feature, a backports package should be created to supply the same functionality for older Pythons.

    Would this effort require a PEP? Is there a good place for such a routine (maybe socketserver)? Any other thoughts?

    @jaraco jaraco added the stdlib Python modules in the Lib dir label Nov 19, 2015
    @bitdancer
    Copy link
    Member

    I don't think it should require a PEP, it looks like a fairly straightforward small enhancement. What is the reason to not put it in the socket module?

    @bitdancer bitdancer added the type-feature A feature request or enhancement label Nov 19, 2015
    @jaraco
    Copy link
    Member Author

    jaraco commented Mar 7, 2016

    No reason not to put it in the socket module. I was thinking originally that the socket module was C only, but on further reflection, it could easily be one of the "additional facilities implemented in Python". Great suggestion.

    @pitrou pitrou added the 3.7 (EOL) end of life label Jan 26, 2017
    @pitrou
    Copy link
    Member

    pitrou commented Jan 27, 2017

    Related though with a different strategy: Tornado's bind_sockets() routine:
    https://github.com/tornadoweb/tornado/blob/master/tornado/netutil.py#L114-L138

    @jaraco
    Copy link
    Member Author

    jaraco commented Dec 17, 2018

    I believe this issue is a duplicate of 17561, which I stumbled onto today.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @lgommans
    Copy link

    As jaraco mentioned, I think this can be closed in favor of #61761 unless we want another solution for UDP specifically (because the create_server function in which this was implemented creates a TCP socket only).

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants