On 26/08/16 13:43, Tigran Bayburtsyan wrote:
Hi All.
I'm writing multithreaded application based on libuv and now I'm in trouble.
I can't understand how to accept connection from one thread, read some
validation data from it and then transfer that connection to another
thread for reading remaining data.
I found some examples for multiprocess communication using UV_PIPE-s,
but in all that examples master process just sending notification to
accept connection.

What I need is accept connection from one thread and then without
closing connection start reading from another thread.
Is there any solution for that ? even if I need to hack something.

|

// Accept connection
    if(uv_accept(server,(uv_stream_t*)client)==0){

       ..................
       ..................

        // how can I call uv_read_start for a different loop ???
        intr =uv_read_start((uv_stream_t*)client,alloc_cb,on_read);
        if(r){
            uv_close((uv_handle_t*)client,close_client);
            return;
        }

    }else{
        uv_close((uv_handle_t*)client,close_client);
    }

|


You need to send the handle from one loop to another, just in the multi-process examples you saw. A handle it tied to a given loop, so if you want to use from a different one, you must use uv_write2 and send the handle over a pipe to the loop running on the other thread.


Cheers,

--
Saúl Ibarra Corretgé
http://bettercallsaghul.com

--
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 https://groups.google.com/group/libuv.
For more options, visit https://groups.google.com/d/optout.

Reply via email to