mirror of
https://github.com/BOSWatch/BW3-Core.git
synced 2025-12-06 07:12:04 +01:00
edit server and client class
- server: bind not only to local - bind to all - client improve error handling
This commit is contained in:
parent
f0d19eaba0
commit
34ed9c3d5b
|
|
@ -47,11 +47,13 @@ class TCPClient:
|
|||
|
||||
logging.debug("connected to " + str(host) + ":" + str(port))
|
||||
return True
|
||||
except socket.timeout:
|
||||
logging.warning("cannot connect to %s:%s - timeout after %s sec", str(host), str(port), self._timeout)
|
||||
except ConnectionRefusedError:
|
||||
logging.error("cannot connect - connection refused")
|
||||
logging.error("cannot connect to %s:%s - connection refused", str(host), str(port))
|
||||
return False
|
||||
except: # pragma: no cover
|
||||
logging.exception("cannot connect to " + str(host) + ":" + str(port))
|
||||
logging.exception("cannot connect to %s:%s", str(host), str(port))
|
||||
return False
|
||||
|
||||
def disconnect(self):
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ class TCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
|
|||
|
||||
@return True or False"""
|
||||
try:
|
||||
self._server = socketserver.ThreadingTCPServer(("localhost", port), TCPHandler)
|
||||
self._server = socketserver.ThreadingTCPServer(("", port), TCPHandler)
|
||||
self._server.timeout = self._timeout
|
||||
|
||||
self.flushData()
|
||||
|
|
|
|||
Loading…
Reference in a new issue