Fix ConnectionResetError not flagging the socket as disconnected

This commit is contained in:
Lonami Exo 2017-06-27 10:18:35 +02:00
parent b0173c3ec2
commit 0cfbf63eaf

View File

@ -96,8 +96,9 @@ class TcpClient:
try: try:
partial = self._socket.recv(bytes_left) partial = self._socket.recv(bytes_left)
if len(partial) == 0: if len(partial) == 0:
self.connected = False
raise ConnectionResetError( raise ConnectionResetError(
'The server has closed the connection (recv() returned 0 bytes).') 'The server has closed the connection.')
buffer.write(partial) buffer.write(partial)
bytes_left -= len(partial) bytes_left -= len(partial)