micropython / micropython-esp32

Old port of MicroPython to the ESP32 -- new port is at https://github.com/micropython/micropython
MIT License
673 stars 216 forks source link

usocket.getaddrinfo() returns an empty list #175

Closed peterhinch closed 6 years ago

peterhinch commented 6 years ago

Using today's build:

MicroPython v1.9.1-477-g75ead22c on 2017-09-05; ESP32 module with ESP32
Type "help()" for more information.
>>> 
>>> import usocket as socket
I (175278) modsocket: Initializing
>>> socket.getaddrinfo('iot.eclipse.org', 1883)
[]
>>> socket.getaddrinfo('google.com', 80)
[]
>>> 
MrSurly commented 6 years ago

Taking your example at face value, how would DNS work w/o any sort of network connection? Or does getaddrinfo always return something?

peterhinch commented 6 years ago

Sorry - I'm too used to the ESP8266. It works fine.

ulidtko commented 1 year ago

Or does getaddrinfo always return something?

On success — yes. Per both POSIX and IETF RFC 2553:

... and, in absence of errors, one or more results shall be returned.

Upon successful return a pointer to a linked list of one or more addrinfo structures is returned ...

As an implementor of getaddrinfo — you would signal "network down" / "DNS unavailable" conditions by error return: e.g. EAI_SERVICE, EAI_AGAIN, EAI_SYSTEM (and in python: exceptions) — not by "successfully" returning empty list.

dpgeorge commented 1 year ago

The current version of the esp32 port of MicroPython is found at https://github.com/micropython/micropython/, and it does now raise an exception (an OSError) if there is no network connection when calling getaddrinfo.

ulidtko commented 1 year ago

Hey @dpgeorge, thanks for your comment... Glad to hear. I'd recommend archiving this repo if it's by now of historical interest only; it's a bit too easy to miss the readme notice, because issues also get indexed by search engines.

dpgeorge commented 11 months ago

I will archive this repo.