diff --git a/mcstatus/protocol/connection.py b/mcstatus/protocol/connection.py index ff2c0c8..9c65c17 100644 --- a/mcstatus/protocol/connection.py +++ b/mcstatus/protocol/connection.py @@ -149,6 +149,9 @@ class TCPSocketConnection(Connection): def write(self, data): self.socket.send(data) + def __del__(self): + self.socket.close() + class UDPSocketConnection(Connection): def __init__(self, addr, timeout=3): @@ -175,4 +178,7 @@ class UDPSocketConnection(Connection): def write(self, data): if isinstance(data, Connection): data = bytearray(data.flush()) - self.socket.sendto(data, self.addr) \ No newline at end of file + self.socket.sendto(data, self.addr) + + def __del__(self): + self.socket.close() \ No newline at end of file