Fallback to localhost if IP of current hostname can't be determined

This commit is contained in:
Andy Kittner 2012-04-27 22:54:20 +02:00
parent 2c2a99d738
commit 7b8f882f0d

View File

@ -67,7 +67,10 @@ def main(argv = None):
def detect_listen_opts(address, port): def detect_listen_opts(address, port):
if address is None: if address is None:
try:
address = socket.gethostbyname(socket.gethostname()) address = socket.gethostbyname(socket.gethostname())
except socket.error:
address = "127.0.0.1"
if port is None: if port is None:
# test if we can use port 80 # test if we can use port 80