File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 6
6
from base64 import b64encode
7
7
from hashlib import sha1
8
8
import logging
9
+ from socket import error as SocketError
10
+ import errno
9
11
10
12
if sys .version_info [0 ] < 3 :
11
13
from SocketServer import ThreadingMixIn , TCPServer , StreamRequestHandler
@@ -189,10 +191,13 @@ def read_bytes(self, num):
189
191
def read_next_message (self ):
190
192
try :
191
193
b1 , b2 = self .read_bytes (2 )
192
- except ConnectionResetError :
193
- logger .info ("Client closed connection." )
194
- self .keep_alive = 0
195
- return
194
+ except SocketError as e : # to be replaced with ConnectionResetError for py3
195
+ if e .errno == errno .ECONNRESET :
196
+ logger .info ("Client closed connection." )
197
+ print ("Error: {}" .format (e ))
198
+ self .keep_alive = 0
199
+ return
200
+ b1 , b2 = 0 , 0
196
201
except ValueError as e :
197
202
b1 , b2 = 0 , 0
198
203
You can’t perform that action at this time.
0 commit comments