socket.getaddrinfo takes too long to respond
Posted: Mon Aug 12, 2019 6:08 am
I'm trying to use socket library in my application on ESP32. I'm trying to connect to a device via it's IP address using the command below-
sock.connect(socket.getaddrinfo(device_IP, device_port)[0][-1])
I noticed that it takes around 19-20 seconds whenever there is a failure in connection or I put wrong IP address, after which it responds with this error:
[Errno 113] EHOSTUNREACH
The timeout argument in socket library doesn't help it and I'm am unable to connect to a device when I configure the socket to be a non-blocking socket.
Is there a way so that I can reduce this waiting time down to 2-4 seconds.
Thanks.
sock.connect(socket.getaddrinfo(device_IP, device_port)[0][-1])
I noticed that it takes around 19-20 seconds whenever there is a failure in connection or I put wrong IP address, after which it responds with this error:
[Errno 113] EHOSTUNREACH
The timeout argument in socket library doesn't help it and I'm am unable to connect to a device when I configure the socket to be a non-blocking socket.
Is there a way so that I can reduce this waiting time down to 2-4 seconds.
Thanks.