catch macos socket errors

This commit is contained in:
ed 2021-02-03 22:32:16 +01:00
parent 0f558ecbbf
commit 280778ed43

View File

@ -53,15 +53,13 @@ class TcpSrv(object):
srv.bind((ip, port)) srv.bind((ip, port))
return srv return srv
except (OSError, socket.error) as ex: except (OSError, socket.error) as ex:
if ex.errno == 98: if ex.errno in [98, 48]:
raise Exception( e = "\033[1;31mport {} is busy on interface {}\033[0m".format(port, ip)
"\033[1;31mport {} is busy on interface {}\033[0m".format(port, ip) elif ex.errno in [99, 49]:
) e = "\033[1;31minterface {} does not exist\033[0m".format(ip)
else:
if ex.errno == 99: raise
raise Exception( raise Exception(e)
"\033[1;31minterface {} does not exist\033[0m".format(ip)
)
def run(self): def run(self):
for srv in self.srv: for srv in self.srv: