- msg_Err( p_this, "Cannot resolve %s port %d : %s", psz_host, i_port,
- vlc_gai_strerror( i_val ) );
- return NULL;
- }
-
- pi_handles = NULL;
- i_size = 1;
-
- for( ptr = res; ptr != NULL; ptr = ptr->ai_next )
- {
- int fd, *newpi;
-
- fd = net_Socket( p_this, ptr->ai_family, ptr->ai_socktype,
- ptr->ai_protocol );
- if( fd == -1 )
- {
- msg_Dbg( p_this, "socket error: %s", net_strerror( net_errno ) );
- continue;
- }
-
- /* Bind the socket */
- if( bind( fd, ptr->ai_addr, ptr->ai_addrlen ) )
- {
- int saved_errno;
-
- saved_errno = net_errno;
- net_Close( fd );
-#if !defined(WIN32) && !defined(UNDER_CE)
- fd = rootwrap_bind( ptr->ai_family, ptr->ai_socktype,
- ptr->ai_protocol, ptr->ai_addr,
- ptr->ai_addrlen );
- if( fd != -1 )
- {
- msg_Dbg( p_this, "got socket %d from rootwrap", fd );
- }
- else
-#endif
- {
- msg_Err( p_this, "cannot bind socket (%s)",
- net_strerror( saved_errno ) );
- continue;
- }
- }
-
- /* Listen */
- if( listen( fd, 100 ) == -1 )
- {
- msg_Err( p_this, "cannot bring the socket in listening mode (%s)",
- net_strerror( net_errno ) );
- net_Close( fd );
- continue;
- }
-
- newpi = (int *)realloc( pi_handles, (++i_size) * sizeof( int ) );
- if( newpi == NULL )
- {
- net_Close( fd );
- break;
- }
- else
- {
- newpi[i_size - 2] = fd;
- pi_handles = newpi;
- }