QUERY · ISSUE
unix usocket: External representation of (binary) addresses
rfc
Ok, https://github.com/micropython/micropython/pull/1002 was closed, because approach of requiring usage of getaddrinfo() to pass addresses to socket functions certainly works. But there's opposite problem - how to show to user an address received from a socket function, e.g. accept(), which doesn't have any solution now. I can imagine following choices:
- Give up and return Python-standard tuple representation of addresses, then almost certainly also need to accept them to all other functions. Bunch more extra code, memory required for minimal socket server grows.
- Stay stubborn and make sockaddr a separate object, which will do conversion only on str() or repr(). No extra RAM overhead with this solution, but object will be more or less involved, e.g. standard Python tuple should be emulated.
- Stay stubborn and low-profile - just provide a function to convert binary address to Python tuple.
Thoughts?
CANDIDATE · ISSUE
Unix (only) socket.getaddrinfo() fails
This would appear to be a regression. Built from today's source.
Unix:
$ upython
MicroPython v1.8.7-1080-g394c536-dirty on 2017-08-20; linux version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>> import usocket as socket
>>> socket.getaddrinfo('iot.eclipse.org', 1883)[0][-1]
bytearray(b'\x02\x00\x07[\xc6)\x1e\xf1\x00\x00\x00\x00\x00\x00\x00\x00')
>>>
ESP8266:
MicroPython v1.8.7-1080-g394c536-dirty on 2017-08-20; ESP module with ESP8266
Type "help()" for more information.
>>>
>>> ipm open,type:2 0
>>> import usocket as socket
>>> socket.getaddrinfo('iot.eclipse.org', 1883)[0][-1]
('198.41.30.241', 1883)
>>>