I'm trying to troubleshoot connection issues across a network, trying to see why some users can see a box right as it's powered on and others can take nearly 20 seconds to see it. It's causing some fatal issues in our local programs.
To that end, I ran up a simple minimum verifiable python script to try and figure out what's up:
import socket
import time
import errno
HOST = '192.168.1.1'
PORT = 12345
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(1)
while(True):
err = s.connect_ex((HOST, PORT))
if err == 0:
print("CONNECTED")
else:
print("NO CONNECTION: {0}".format(errno.errorcode[err]))
time.sleep(2)
When I run this code, I see a consistent pattern: EAGAIN, followed by 10 instances of EALREADY. When it DOES connect, 'CONNECTED' replaces the EAGAIN bit of the cycle.
I thought that setting the timeout to 1 second, and waiting for 2 seconds, should let me abort the connect call in the background faster, but it seems to have no effect whatsoever. Is there a TCP option I can set, or Windows setting I can tweak, to ensure that I don't have these awkward 20 second blocks while I'm polling the remote box for connectivity?