Hi, libuver

        In my server program I need to get the real socket handle(fd) after
I call uv_accept.
        Whether I can get it? and How to do it?

        Here is the code snippet from echo-server.c, after it call
uv_accecpt.
        The uv_accept will return the uv_stream_t* type -- stream.
        Here how can I get the socket fd from stream variable?

----------------------------------- code-snippet from libuv-0.10.25
-----------------------------------------------------

    static void on_connection ( uv_stream_t* server, int status )
    {
        uv_stream_t* stream;
        int r;

        if ( status != 0 )
        {
            fprintf ( stderr, "Connect error %d\n",
                      uv_last_error ( loop ).code );
        }
        ASSERT ( status == 0 );

        switch ( serverType )
        {
        case TCP:
            stream = malloc ( sizeof ( uv_tcp_t ) );
            ASSERT ( stream != NULL );
            r = uv_tcp_init ( loop, ( uv_tcp_t* ) stream );
            ASSERT ( r == 0 );
            break;

        case PIPE:
            stream = malloc ( sizeof ( uv_pipe_t ) );
            ASSERT ( stream != NULL );
            r = uv_pipe_init ( loop, ( uv_pipe_t* ) stream, 0 );
            ASSERT ( r == 0 );
            break;

        default:
            ASSERT ( 0 && "Bad serverType" );
            abort();
        }

        /* associate server with stream */
        stream->data = server;

        r = uv_accept ( server, stream );
        ASSERT ( r == 0 );

        /// for libuv-v0.10.25
        /// Here how can I get the socket fd(handle) from `stream` returned
by uv_accept()?

        r = uv_read_start ( stream, echo_alloc, after_read );
        ASSERT ( r == 0 );
    }

-- 

     _                         __ _     _
 ___| |__   ___ _ __   __ _   / _(_)___| |__
|_  / '_ \ / _ \ '_ \ / _` | | |_| / __| '_ \
 / /| | | |  __/ | | | (_| | |  _| \__ \ | | |
/___|_| |_|\___|_| |_|\__, | |_| |_|___/_| |_|
                      |___/

-- 
You received this message because you are subscribed to the Google Groups 
"libuv" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/libuv.
For more options, visit https://groups.google.com/d/optout.

Reply via email to