[Help] IPv6 Link-local scope id
In Ipv6, when send to a link-local address, the scope-id must be set in sockaddr_in6 struct. It is the index of the interface that is used to communicate with the link-local address.
For example, on my machine, the interface index used is 4. I have to set
addrV6.sin6_scope_id = 4;
Only then can I sendto(). If I leave it unspecified as 0, I got error.
My question is, how to retrieve this interface index? I don't think I should set it 4, or any other fixed number, since the index could be totally different on another machine. I googled quite a bit online, and didn't find anything too useful. Any ideas? Thanks!