diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-10-29 16:44:37 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-10-29 16:44:37 (GMT) |
commit | e16e54f7f1c0f9efaae7084b8fcbdfa95e99026b (patch) | |
tree | 83a0249b9b70b7b93a20f13454e1f0e39b5dbf28 | |
parent | fbd5797eb7aa2f2e291a11081f5c5160614fdd45 (diff) | |
download | cpython-e16e54f7f1c0f9efaae7084b8fcbdfa95e99026b.zip cpython-e16e54f7f1c0f9efaae7084b8fcbdfa95e99026b.tar.gz cpython-e16e54f7f1c0f9efaae7084b8fcbdfa95e99026b.tar.bz2 |
Use connect_ex() instead of connect().
Removes old XXX comment and possible source of long-delays.
-rw-r--r-- | Lib/asyncore.py | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/Lib/asyncore.py b/Lib/asyncore.py index 613804d..684e5d2 100644 --- a/Lib/asyncore.py +++ b/Lib/asyncore.py @@ -53,7 +53,7 @@ import sys import os from errno import EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, \ - ENOTCONN, ESHUTDOWN, EINTR + ENOTCONN, ESHUTDOWN, EINTR, EISCONN try: socket_map @@ -301,17 +301,14 @@ class dispatcher: def connect (self, address): self.connected = 0 - # XXX why not use connect_ex? - try: - self.socket.connect (address) - except socket.error, why: - if why[0] in (EINPROGRESS, EALREADY, EWOULDBLOCK): - return - else: - raise socket.error, why - self.addr = address - self.connected = 1 - self.handle_connect() + err = self.socket.connect_ex(address) + if err in (EINPROGRESS, EALREADY, EWOULDBLOCK): + return + if err in (0, EISCONN): + self.addr = address + self.connected = 1 + self.handle_connect() + raise socket.error, err def accept (self): try: |