git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Checking support for network connections from Python client to IPv6 server


On Sun, Jun 2, 2019 at 5:17 PM Markus Elfring <Markus.Elfring at web.de> wrote:
>
> >> How would like to explain the error message ?socket.gaierror: [Errno -9]
> >> Address family for hostname not supported? on my Linux test system then?
> >
> > Can you supply a tiny standalone piece of code demonstrating this error please?
>
> The following script part would be relevant.
>
> ?
> def send_data(x):
>    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as so:
>        global args
>        so.connect((args.server_id, args.server_port))
> ?
>
>
> If the address family ?AF_INET6? was passed instead, the identification ?::1?
> can work also as a command parameter.
> The data transmission seems to succeed by my script ?socket-send_json_data2.py? then.
>

May I recommend using this function instead? It'll be easier to handle
both IPv4 and IPv6:

https://docs.python.org/3/library/socket.html#socket.create_connection

ChrisA