Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #79926
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!bloom-beacon.mit.edu!bloom-beacon.mit.edu!panix!not-for-mail |
|---|---|
| From | Grant Edwards <invalid@invalid.invalid> |
| Newsgroups | comp.lang.python |
| Subject | Re: Send UDP packet to link-local IPv6 address? |
| Date | Wed, 29 Oct 2014 17:36:30 +0000 (UTC) |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Lines | 43 |
| Message-ID | <m2r8iu$r3k$1@reader1.panix.com> (permalink) |
| References | <m2r149$ej8$1@reader1.panix.com> <87zjce252h.fsf@dpt-info.u-strasbg.fr> |
| NNTP-Posting-Host | 67-130-15-94.dia.static.qwest.net |
| X-Trace | reader1.panix.com 1414604190 27764 67.130.15.94 (29 Oct 2014 17:36:30 GMT) |
| X-Complaints-To | abuse@panix.com |
| NNTP-Posting-Date | Wed, 29 Oct 2014 17:36:30 +0000 (UTC) |
| User-Agent | slrn/1.0.1 (Linux) |
| Xref | csiph.com comp.lang.python:79926 |
Show key headers only | View raw
On 2014-10-29, Alain Ketterlin <alain@dpt-info.u-strasbg.fr> wrote:
> 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()).
Doh!, of course that works. Using getaddrinfo() is how you're always
supposed to do things these days. Creating an address tuple by hand
is a bad habit left over from too many years spent doing network stuff
in the old days before getaddrinfo et al. I looked at the
documentation for getaddrinfo(), and I would have sworn I had tried it
and couldn't get it to work. But it does.
> Hope this helps,
Definitely!
Thanks!
--
Grant Edwards grant.b.edwards Yow! FOOLED you! Absorb
at EGO SHATTERING impulse
gmail.com rays, polyester poltroon!!
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll 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