Network input problem

Christophe Massiot massiot at via.ecp.fr
Wed Nov 21 12:23:41 CET 2001


I have a problem with the connect() statement in the network input of VLC.
Here is what we do :

    /* Build socket for remote connection */
    if ( network_BuildRemoteAddr( &sock, psz_server ) == -1 )
    {
        intf_ErrMsg( "input error: can't build remote address" );
        close( p_input->i_handle );
        p_input->b_error = 1;
        return;
    }

    /* Only connect if the user has passed a valid host */
    if( sock.sin_addr.s_addr != INADDR_ANY )
    {
        /* Connect the socket */
        if( connect( p_input->i_handle, (struct sockaddr *) &sock,
                     sizeof( sock ) ) == (-1) )
        {
            intf_ErrMsg( "input error: can't connect socket (%s)",
                         strerror(errno) );
            close( p_input->i_handle );
            p_input->b_error = 1;
            return;
        }
    }

The reason we do that on the UDP socket is to only receive the packets
coming from the server (psz_server), and not the ones coming from
a bogus dummy crackerz.

This works perfectly on my linux box. This works perfectly under Win2K.
It doesn't work Win98 and on certain versions of Linux (you get
an "invalid argument" error, known as "the --broadcast workaround").

I'm not surprised for Win98 (hum), but I'm surprised for Linux. I
haven't manage to track it down to a specific kernel version ; instead,
I suspect a glibc difference (from 2.1, which I use, to 2.2), or
an IPv6 difference (which I don't use at all).

A basic workaround is to disable the connect() call, which we don't
absolutely need, but it bothers me. What do you think on the subject ?

-- 
Christophe Massiot.




More information about the vlc-devel mailing list