From 280778ed436ce1747b8ce83505d5ca32888f8830 Mon Sep 17 00:00:00 2001 From: ed Date: Wed, 3 Feb 2021 22:32:16 +0100 Subject: [PATCH] catch macos socket errors --- copyparty/tcpsrv.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/copyparty/tcpsrv.py b/copyparty/tcpsrv.py index c207dbfa..71c8997c 100644 --- a/copyparty/tcpsrv.py +++ b/copyparty/tcpsrv.py @@ -53,15 +53,13 @@ class TcpSrv(object): srv.bind((ip, port)) return srv except (OSError, socket.error) as ex: - if ex.errno == 98: - raise Exception( - "\033[1;31mport {} is busy on interface {}\033[0m".format(port, ip) - ) - - if ex.errno == 99: - raise Exception( - "\033[1;31minterface {} does not exist\033[0m".format(ip) - ) + if ex.errno in [98, 48]: + e = "\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: + raise + raise Exception(e) def run(self): for srv in self.srv: