Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #79922

Re: Send UDP packet to link-local IPv6 address?

From Alain Ketterlin <alain@dpt-info.u-strasbg.fr>
Newsgroups comp.lang.python
Subject Re: Send UDP packet to link-local IPv6 address?
Date 2014-10-29 17:50 +0100
Organization Universites Paris VI/Paris VII - France
Message-ID <87zjce252h.fsf@dpt-info.u-strasbg.fr> (permalink)
References <m2r149$ej8$1@reader1.panix.com>

Show all headers | View raw


Grant Edwards <invalid@invalid.invalid> writes:

[...]
> With link-local addresses you also need to specify which interface to
> use. The normal way of doing this on Linux with command-line utilities
> is append %<ifname> to the address/hostname (e.g. ping6 ff02::1%net1).
>
> That doesn't work:
>
> s.sendto(data, ("ff02::1%net1",port))
> s.sendto(data, ("fe80::2c0:4eff:fe40:5f%net1",port))
>
> The "%net1" appears to be ignored, and the packet will go out _some_
> interface, but I can't figure out how it decides which one (it's not
> always the same one).

The only way I've found is to use socket.getaddrinfo(), which does
accept "%net1" after the IPv6 address, and returns scope_id (actually a
complete sockaddr). I can't access my files now, by I think

    socket.getaddrinfo("fe80::2c0:4eff:fe40:5f%net1",port,...)

should work for you (family, socktype etc should be passed also to avoid
searching the results of getaddrinfo()).

Hope this helps,

-- Alain.

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Send UDP packet to link-local IPv6 address? Grant Edwards <invalid@invalid.invalid> - 2014-10-29 15:29 +0000
  Re: Send UDP packet to link-local IPv6 address? Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2014-10-29 17:50 +0100
    Re: Send UDP packet to link-local IPv6 address? Grant Edwards <invalid@invalid.invalid> - 2014-10-29 17:36 +0000

csiph-web