serious rresvport problem in python 2.2.1
strombrg at tesuji.nac.uci.edu
Tue Aug 13 01:32:26 CEST 2002
I've been using a modified version of Carey Evans' rresvport function
in a printsystem.
It worked fine in python 2.1.2 and python 2.1.3.
Unfortunately, it's not working out in 2.2.1.
I've included at the bottom, the rresvport module I've been using with
2.1.2 and 2.1.3.
The error I get is:
Traceback (most recent call last):
File "./t", line 6, in ?
s = rresvport.rresvport()
File "./rresvport.py", line 41, in rresvport
socket.gaierror: (3, 'getaddrinfo failed')
So I got kind of interested in that '' in the bind call. This is
supposed to mean "localhost". So I changed it to
bind(('localhost',port)). This allows me to locate a port, but then a
subsequent connect() using said port gives:
socket.error: (126, 'Cannot assign requested address')
What do I need to get this working again?
Here's the rresvport module we've been using with 2.1.2 and 2.1.3:
# this one's from
# Carey Evans c.evans at clear.net.nz
return 'No reserved ports available'
port = 1023
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
while port >= 1:
# tuple for 2.1, probably non-tuple for pre-2.0
# This was in Carey's original code, but didn't work for me with python 2.1
# if type(detail) is not types.TupleType \
# or detail != errno.EADDRINUSE:
# This is a working replacement.
## this used to work with 2.1.2 and 2.1.3, but doesn't with 2.2.1:
if detail != errno.EADDRINUSE:
port = port - 1
Dan Stromberg UCI/NACS/DCS
More information about the Python-list