5555import os
5656from errno import EALREADY , EINPROGRESS , EWOULDBLOCK , ECONNRESET , EINVAL , \
5757 ENOTCONN , ESHUTDOWN , EINTR , EISCONN , EBADF , ECONNABORTED , EPIPE , EAGAIN , \
58- errorcode
58+ errorcode , \
59+ WSAEWOULDBLOCK , WSAENOTCONN , WSAEINPROGRESS , WSAEALREADY , WSAEISCONN , \
60+ WSAECONNABORTED , WSAENOTCONN , WSAEBADF
5961
6062_DISCONNECTED = frozenset ((ECONNRESET , ENOTCONN , ESHUTDOWN , ECONNABORTED , EPIPE ,
61- EBADF ))
63+ EBADF , WSAENOTCONN , WSAECONNABORTED , WSAEBADF ))
6264
6365try :
6466 socket_map
@@ -249,7 +251,7 @@ def __init__(self, sock=None, map=None):
249251 try :
250252 self .addr = sock .getpeername ()
251253 except socket .error , err :
252- if err .args [0 ] in (ENOTCONN , EINVAL ):
254+ if err .args [0 ] in (ENOTCONN , EINVAL , WSAENOTCONN ):
253255 # To handle the case where we got an unconnected
254256 # socket.
255257 self .connected = False
@@ -345,7 +347,7 @@ def connect(self, address):
345347 self .connected = False
346348 self .connecting = True
347349 err = self .socket .connect_ex (address )
348- if err in (EINPROGRESS , EALREADY , EWOULDBLOCK ) \
350+ if err in (EINPROGRESS , EALREADY , EWOULDBLOCK , WSAEINPROGRESS , WSAEALREADY , WSAEWOULDBLOCK ) \
349351 or err == EINVAL and os .name in ('nt' , 'ce' ):
350352 self .addr = address
351353 return
@@ -362,7 +364,7 @@ def accept(self):
362364 except TypeError :
363365 return None
364366 except socket .error as why :
365- if why .args [0 ] in (EWOULDBLOCK , ECONNABORTED , EAGAIN ):
367+ if why .args [0 ] in (EWOULDBLOCK , ECONNABORTED , EAGAIN , WSAEWOULDBLOCK , WSAECONNABORTED ):
366368 return None
367369 else :
368370 raise
@@ -374,7 +376,7 @@ def send(self, data):
374376 result = self .socket .send (data )
375377 return result
376378 except socket .error , why :
377- if why .args [0 ] == EWOULDBLOCK :
379+ if why .args [0 ] in ( EWOULDBLOCK , WSAEWOULDBLOCK ) :
378380 return 0
379381 elif why .args [0 ] in _DISCONNECTED :
380382 self .handle_close ()
@@ -408,7 +410,7 @@ def close(self):
408410 try :
409411 self .socket .close ()
410412 except socket .error , why :
411- if why .args [0 ] not in (ENOTCONN , EBADF ):
413+ if why .args [0 ] not in (ENOTCONN , EBADF , WSAENOTCONN , WSAEBADF ):
412414 raise
413415
414416 # cheap inheritance, used to pass all other attribute
0 commit comments