Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e16e54f

Browse files
committed
Use connect_ex() instead of connect().
Removes old XXX comment and possible source of long-delays.
1 parent fbd5797 commit e16e54f

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

Lib/asyncore.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454
import os
5555
from errno import EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, \
56-
ENOTCONN, ESHUTDOWN, EINTR
56+
ENOTCONN, ESHUTDOWN, EINTR, EISCONN
5757

5858
try:
5959
socket_map
@@ -301,17 +301,14 @@ def bind (self, addr):
301301

302302
def connect (self, address):
303303
self.connected = 0
304-
# XXX why not use connect_ex?
305-
try:
306-
self.socket.connect (address)
307-
except socket.error, why:
308-
if why[0] in (EINPROGRESS, EALREADY, EWOULDBLOCK):
309-
return
310-
else:
311-
raise socket.error, why
312-
self.addr = address
313-
self.connected = 1
314-
self.handle_connect()
304+
err = self.socket.connect_ex(address)
305+
if err in (EINPROGRESS, EALREADY, EWOULDBLOCK):
306+
return
307+
if err in (0, EISCONN):
308+
self.addr = address
309+
self.connected = 1
310+
self.handle_connect()
311+
raise socket.error, err
315312

316313
def accept (self):
317314
try:

0 commit comments

Comments
 (0)