vshymanskyy / blynk-library-python

Blynk library for Python. Works with Python 2, Python 3, MicroPython.
https://blynk.io/
MIT License
286 stars 98 forks source link

Added support for servers with IPv6 addresses. #74

Open simontuckwell opened 1 year ago

simontuckwell commented 1 year ago

The current code doesn't support Blynk servers using IPv6 addresses as the socket defaults to IPv4 (family AF_INET) and the address tuple returned by getaddrinfo() has extra values for an IPv6 host.

These changes use the family, type and proto returned by getaddrinfo() and remove the extra values in the address tuple before opening the socket.

The new code also filters the type and proto in the call to getaddrinfo() so that fewer tuples are returned. It still uses only the first element in the list.

Tested on Fedora Linux and Python 3.11.3.