Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use libev for one event, waiting two sockets by two ev_io and ev_watch?
    primarykey
    data
    text
    <p>Now I'm writing a proxy server for a specify true server.</p> <p>The architecture of the system can be represent by the graph below:</p> <p>(I actually use multi-threads to handle all clients.)</p> <p><strong>'client A'</strong> ←––––– –––––→ <strong>'proxy server'</strong> ←––––– –––––→ <strong>'true Server'</strong>     </p> <hr> <p>I use "libev.h" to implement it, so one event need to listen two socket.</p> <p>I find some example like:</p> <pre><code>struct MYIO w { ev_io io; int serverfd; int clientfd; } int main() { ... struct MYIO w; w.clientfd = new_tcp_client ("127.0.0.1", 12346); ev_io_init (&amp;w.io, client2proxy_func, clientfd, EV_READ); ev_io_start (loop, &amp;w_io); ev_timer_init (&amp;timeout_watcher, timer_func, 5, 0.); ev_timer_start (loop, &amp;timeout_watcher); ... } </code></pre> <p>This only for one io event.</p> <p>If I want to wait two io_ev then it didn't work... like this below:</p> <p>(I also try some different way but all failed.)</p> <pre><code>... w.clientfd = new_tcp_client ("127.0.0.1", 12346); w.serverfd = new_tcp_server ("127.0.0.1", 12345); ev_io_init (&amp;w.io, client2proxy_func, clientfd, EV_READ); ev_io_start (loop, &amp;w_io); ev_io_init (&amp;w.io, proxy2server_func, serverfd, EV_READ); ev_io_start (loop, &amp;w_io); ev_timer_init (&amp;timeout_watcher, timer_func, 5, 0.); ev_timer_start (loop, &amp;timeout_watcher); ... </code></pre> <p>How to use libev in multi-task?</p> <p>How to use libev for one event, waiting two sockets by two ev_io and ev_watch?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload