sock.connect(socket.getaddrinfo(ip,port)[0][-1]) takes too long to respond
I'm trying to use usocket library in my application on ESP32 DevkitC and I want to develop a software where if I input a wrong host address it should respond quickly, reset and try again through a webserver based configuration.
sock.connect(socket.getaddrinfo(slave_ip, slave_port)[0][-1])
During testing, I intentionally input the wrong address and it takes around 19 seconds, after which it responds with this error:
[Errno 113] EHOSTUNREACH
I want to reduce this time so that i can perform some other actions.
P.S: sock.setblocking(False) is not an option.
ESP32: Socket.listen(backlog) leads to OSError: 112
Currently I'm trying to listen to a socket. My setup is utilizing uasyncio.
But the same error is happening with plain use of sockets as well.
I'm building the master branch with EspIDF 3.3.1
import usocket as _socket
ai = _socket.getaddrinfo("0.0.0.0", 80, 0, _socket.SOCK_STREAM)
ai = ai[0]
s = _socket.socket(ai[0], ai[1], ai[2])
s.setblocking(False)
s.setsockopt(_socket.SOL_SOCKET, _socket.SO_REUSEADDR, 1)
s.bind(ai[-1])
s.listen(10)
Edit:
Just finished tests with ESP IDF 4 --> Same problem.