circuitpython/tests/net_hosted/connect_nonblock.py
Thorsten von Eicken 902da05a18 esp32: Set MICROPY_USE_INTERNAL_ERRNO=0 to use toolchain's errno.h.
The underlying OS (the ESP-IDF) uses it's own internal errno codes and so
it's simpler and cleaner to use those rather than trying to convert
everything to the values defined in py/mperrno.h.
2021-02-15 23:47:02 +11:00

22 lines
453 B
Python

# test that socket.connect() on a non-blocking socket raises EINPROGRESS
try:
import usocket as socket
import uerrno as errno
except:
import socket, errno
def test(peer_addr):
s = socket.socket()
s.setblocking(False)
try:
s.connect(peer_addr)
except OSError as er:
print(er.args[0] == errno.EINPROGRESS)
s.close()
if __name__ == "__main__":
test(socket.getaddrinfo("micropython.org", 80)[0][-1])