favalex / modbus-cli

Command line tool to access Modbus devices
Mozilla Public License 2.0
158 stars 30 forks source link

Add support for IPv6 #29

Closed op3 closed 1 month ago

op3 commented 1 month ago

Use urllib.parse.urlsplit to parse hostname + port, defaulting to localhost:502. Use socket.getaddrinfo to determine the suitable address family, an then attempt to connect for every returned addrinfo.

This implementation is compatible with previous behavior for IPv4 hosts, but it enables connecting to IPv6 hosts as well. Examples of device arguments that were previously supported and are still supported:

Examples of device arguments that are newly supported:

In addition, IPv6-only hosts with hostnames that could only be resolved via IPv6 are now also supported.