This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: SocketServer should set SO_REUSEPORT along with SO_REUSEADDR when present
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Andy.Zeldis, asaka, asvetlov, gvanrossum
Priority: normal Keywords: patch

Created on 2012-12-02 09:07 by Andy.Zeldis, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
osc-broadcast-rcv.py Andy.Zeldis, 2012-12-02 09:07 SocketServer broadcast receive workaround
Pull Requests
URL Status Linked Edit
PR 30072 merged asaka, 2021-12-12 13:38
Messages (3)
msg176777 - (view) Author: Andy Zeldis (Andy.Zeldis) Date: 2012-12-02 09:07
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)
msg205125 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2013-12-03 15:54
Note: it is possible that SO_REUSEPORT is defined yet not implemented (and you'll get an OSError when using it).
msg408447 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2021-12-13 12:14
New changeset b56774bd93822e1598bb5d6c1d0b1fe8c45a750d by AN Long in branch 'main':
bpo-16594: Add allow_reuse_port on socketserver (GH-30072)
https://github.com/python/cpython/commit/b56774bd93822e1598bb5d6c1d0b1fe8c45a750d
History
Date User Action Args
2022-04-11 14:57:38adminsetgithub: 60798
2021-12-13 13:33:49asvetlovsetstatus: open -> closed
stage: patch review -> resolved
resolution: fixed
versions: + Python 3.11, - Python 2.7
2021-12-13 12:14:36asvetlovsetnosy: + asvetlov
messages: + msg408447
2021-12-12 13:38:24asakasetkeywords: + patch
nosy: + asaka

pull_requests: + pull_request28292
stage: patch review
2014-05-14 10:51:31skrahsetnosy: - skrah
2013-12-03 15:54:13gvanrossumsetnosy: + gvanrossum
messages: + msg205125
2012-12-02 18:48:28pitrousetnosy: + skrah
2012-12-02 09:07:29Andy.Zeldiscreate