+ char *ptr = strchr (psz_address, '%') + 1;
+ for (unsigned i = 0; l[i].if_index; i++)
+ {
+ strcpy (ptr, l[i].if_name);
+ InitSocket (p_sd, psz_address, SAP_PORT);
+ }
+ if_freenameindex (l);
+ }
+#else
+ /* this is the Winsock2 equivalant of SIOCGIFCONF on BSD stacks,
+ which if_nameindex uses internally anyway */
+
+ // first create a dummy socket to pin down the protocol family
+ SOCKET s = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP);
+ if( s != INVALID_SOCKET )
+ {
+ INTERFACE_INFO ifaces[10]; // Assume there will be no more than 10 IP interfaces
+ size_t len = sizeof(ifaces);
+
+ if( SOCKET_ERROR != WSAIoctl(s, SIO_GET_INTERFACE_LIST, NULL, 0, &ifaces, len, &len, NULL, NULL) )
+ {
+ unsigned ifcount = len/sizeof(INTERFACE_INFO);
+ char *ptr = strchr (psz_address, '%') + 1;
+ for(unsigned i = 1; i<=ifcount; ++i )
+ {
+ // append link-local zone identifier
+ sprintf(ptr, "%d", i);
+ }
+ }
+ closesocket(s);
+ }
+#endif
+ *strchr (psz_address, '%') = '\0';
+
+ static const char ipv6_scopes[] = "1456789ABCDE";
+ for (const char *c_scope = ipv6_scopes; *c_scope; c_scope++)
+ {
+ psz_address[3] = *c_scope;