Skip to content

SocketServer should set SO_REUSEPORT along with SO_REUSEADDR when present #60798

Closed

Description

@AndyZeldis
mannequin
BPO 16594
Nosy @gvanrossum, @asvetlov, @aisk
PRs
  • bpo-16594: Add allow_reuse_port on socketserver #30072
  • Files
  • osc-broadcast-rcv.py: SocketServer broadcast receive workaround
  • 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 = <Date 2021-12-13.13:33:49.165>
    created_at = <Date 2012-12-02.09:07:29.427>
    labels = ['type-bug', 'library', '3.11']
    title = 'SocketServer should set SO_REUSEPORT along with SO_REUSEADDR when present'
    updated_at = <Date 2021-12-13.13:33:49.164>
    user = 'https://bugs.python.org/AndyZeldis'

    bugs.python.org fields:

    activity = <Date 2021-12-13.13:33:49.164>
    actor = 'asvetlov'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-12-13.13:33:49.165>
    closer = 'asvetlov'
    components = ['Library (Lib)']
    creation = <Date 2012-12-02.09:07:29.427>
    creator = 'Andy.Zeldis'
    dependencies = []
    files = ['28183']
    hgrepos = []
    issue_num = 16594
    keywords = ['patch']
    message_count = 3.0
    messages = ['176777', '205125', '408447']
    nosy_count = 4.0
    nosy_names = ['gvanrossum', 'asvetlov', 'Andy.Zeldis', 'asaka']
    pr_nums = ['30072']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue16594'
    versions = ['Python 3.11']

    Activity

    1. AndyZeldis commented on Dec 2, 2012

      AndyZeldismannequin
      MannequinAuthor

      On BSD (including Mac OS X) SO_REUSEPORT should be specified along with SO_REUSEADDR to match behavior on Linux (and possible Windows). This is needed to have multiple listeners to a UDP broadcast.

      I discovered this when using PyOSC. Attached is an example modified to subclass SocketServer with a workaround. It should be possible to start multiple instances of this program, all of which will receive messages to a broadcast address (eg 255.255.255.255:7110).

      This test uses Python 2.7 on OS X (despite the "python3" shebang line from the example)

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or error
      on Dec 2, 2012
    3. gvanrossum commented on Dec 3, 2013

      @gvanrossum
      Member

      Note: it is possible that SO_REUSEPORT is defined yet not implemented (and you'll get an OSError when using it).

    4. asvetlov commented on Dec 13, 2021

      @asvetlov
      Contributor

      New changeset b56774b by AN Long in branch 'main':
      bpo-16594: Add allow_reuse_port on socketserver (GH-30072)
      b56774b

    5. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.11only security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions