#1065 Fix windows not reattempting refused connections

Windows does not report a refused connection the same way as Linux.
Unsuccesful connect socket will be kept in the exceptfds, and won't
be in the readable nor writable fds. The socket in this state will
have SO_ERROR set to ECONNREFUSED.

On the other hand, Linux does not use exceptfds for such case.
more_events
Jose M. Guisado 2021-11-23 11:43:10 +01:00
parent b5d5d29d31
commit 6ddc1da7ca
1 changed files with 5 additions and 1 deletions

View File

@ -143,16 +143,20 @@ class ogClient:
if state == State.CONNECTING:
readset = [ sock ]
writeset = [ sock ]
exceptset = [ sock ]
elif state == State.FORCE_DISCONNECTED:
return 0
else:
readset = [ sock ]
writeset = [ ]
exceptset = [ ]
readable, writable, exception = select.select(readset, writeset, [ ])
readable, writable, exception = select.select(readset, writeset, exceptset)
if state == State.CONNECTING and sock in writable:
self.connect2()
elif state == State.RECEIVING and sock in readable:
self.receive()
elif state == State.CONNECTING and sock in exception:
self.connect2()
else:
print('wrong state, not ever happen!' + str(state))