+ struct addrinfo hints, *res;
+
+ memset (&hints, 0, sizeof( hints ));
+ hints.ai_family = family;
+ hints.ai_socktype = socktype;
+ hints.ai_flags = AI_PASSIVE;
+
+ msg_Dbg (p_this, "net: listening to %s port %d", psz_host, i_port);
+
+ int i_val = vlc_getaddrinfo (p_this, psz_host, i_port, &hints, &res);
+ if (i_val)
+ {
+ msg_Err (p_this, "Cannot resolve %s port %d : %s", psz_host, i_port,
+ vlc_gai_strerror (i_val));
+ return NULL;
+ }
+
+ int *sockv = NULL;
+ unsigned sockc = 0;
+
+ for (struct addrinfo *ptr = res; ptr != NULL; ptr = ptr->ai_next)
+ {
+ int fd = net_Socket (p_this, ptr->ai_family, ptr->ai_socktype,
+ protocol ?: ptr->ai_protocol);
+ if (fd == -1)
+ {
+ msg_Dbg (p_this, "socket error: %s", net_strerror (net_errno));
+ continue;
+ }
+
+ /* Bind the socket */
+#if defined (WIN32) || defined (UNDER_CE)
+ /*
+ * Under Win32 and for multicasting, we bind to INADDR_ANY.
+ * This is of course a severe bug, since the socket would logically
+ * receive unicast traffic, and multicast traffic of groups subscribed
+ * to via other sockets.
+ */
+ if (net_SockAddrIsMulticast (ptr->ai_addr, ptr->ai_addrlen)
+ && (sizeof (struct sockaddr_storage) >= ptr->ai_addrlen))
+ {
+ // This works for IPv4 too - don't worry!
+ struct sockaddr_in6 dumb =
+ {
+ .sin6_family = ptr->ai_addr->sa_family,
+ .sin6_port = ((struct sockaddr_in *)(ptr->ai_addr))->sin_port
+ };
+
+ bind (fd, (struct sockaddr *)&dumb, ptr->ai_addrlen);
+ }
+ else