From 010770684db95bece206943768621f2c7c27bace Mon Sep 17 00:00:00 2001 From: ed Date: Sat, 14 Jan 2023 08:16:15 +0000 Subject: [PATCH] workaround another linux kernel bug --- copyparty/tcpsrv.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/copyparty/tcpsrv.py b/copyparty/tcpsrv.py index 122ee6a8..507fa7c2 100644 --- a/copyparty/tcpsrv.py +++ b/copyparty/tcpsrv.py @@ -1,6 +1,7 @@ # coding: utf-8 from __future__ import print_function, unicode_literals +import errno import os import re import socket @@ -223,6 +224,11 @@ class TcpSrv(object): try: srv.bind((ip, port)) + sport = srv.getsockname()[1] + if port != sport: + # linux 6.0.16 lets you bind a port which is in use + # except it just gives you a random port instead + raise OSError(errno.EADDRINUSE, "") self.srv.append(srv) except (OSError, socket.error) as ex: if ex.errno in E_ADDR_IN_USE: