[ds6] Re: (usagi-users 03345) Bind on an AF_INET6 socket issue

David Stevens dlstevens at us.ibm.com
Tue May 10 03:36:37 CEST 2005


You can bind to link-local addresses. You need to specify which
interface by setting the sin6_scope_id value to the index of the
interface. I expect the scope_id wasn't set to a valid index to get
the ENODEV.

You want something like:

        sin6.sin6_family = AF_INET6;
        sin6.sin6_port = htonl(myport);
        sin6.sin6_scope_id = if_nametoindex("eth0");
        if (inet_pton(AF_INET6, "fe80::2a0:9cff:fe00:436", 
&sin6.sin6_addr) <= 0) {
                /* error */
                exit(1);
        }
        if (bind(s, (struct sockaddr *)&sin6, sizeof(sin6)) < 0) {
                perror("bind");
                exit(1);
        }
        ...

                                +-DLS



More information about the ds6 mailing list