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.TCPServer returns different ports
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: collinwinter, damonkohler, hakker_de
Priority: normal Keywords:

Created on 2006-07-31 19:58 by hakker_de, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg29405 - (view) Author: hakker.de (hakker_de) Date: 2006-07-31 19:58
Providing 0 as a port in __init__ of 
SocketServer.TCPServer leads to different values for 
port in server_address and socket.getsockname().

Example:
import SocketServer
s = SocketServer.TCPServer(("0.0.0.0", 0), Handler)
s.server_address
-> ('0.0.0.0', 0)
s.socket.getsockname()
-> ('0.0.0.0', 39129)

s.server_address should also contain 39129 as the 
port number for the free port found.
msg29406 - (view) Author: Damon Kohler (damonkohler) Date: 2006-08-23 01:36
Logged In: YES 
user_id=705317

Patch 1545011 is a proposed fix.
msg29407 - (view) Author: Collin Winter (collinwinter) * (Python committer) Date: 2007-03-10 00:32
hakker, you marked this as "fixed"; was that intentional?
msg29408 - (view) Author: Collin Winter (collinwinter) * (Python committer) Date: 2007-03-10 03:33
Fixed in r54253 (for 2.6), r54255 (for 2.5.1). Thanks for the bug report!
History
Date User Action Args
2022-04-11 14:56:19adminsetgithub: 43755
2006-07-31 19:58:14hakker_decreate