I&#39;ve already managed to get it to work, thanks to the hopmod guys (reactor branch).<br><br><a href="http://code.google.com/p/frogmod/source/detail?r=193">http://code.google.com/p/frogmod/source/detail?r=193</a><br><br>
It seems enet_host_service is used without a timeout, so it doesn&#39;t block.<br><br>Thanks for replying!<br><br><br><div class="gmail_quote">On Tue, Aug 4, 2009 at 1:27 PM, Uj <span dir="ltr">&lt;<a href="mailto:ujdevil@gmail.com">ujdevil@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Mihai,<br><br>enet_host_service() is essential in Enet, since it handles all the connectivity of the network engine (reliability, disconnections...)<br>
I think you&#39;re about to miss what enet is designed for, and your code just won&#39;t work.<br>

<br>Maybe you should go TCP and I/O ports?<br><br>regards,<br>Ju<br><br><br><div class="gmail_quote"><div><div></div><div class="h5">On Sat, Aug 1, 2009 at 3:45 PM, Mihai Draghicioiu <span dir="ltr">&lt;<a href="mailto:mihai.draghicioiu@gmail.com" target="_blank">mihai.draghicioiu@gmail.com</a>&gt;</span> wrote:<br>


</div></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="h5">Hi all. I&#39;m working on frogmod, a sauerbraten server. At first it used the original sauer main loop, then I changed it to use a loop similar to BloodFrontier (checks for events then sleeps for 1ms), but now I want to make it work with libevent. The way libevent works -- you receive a callback for each event that happens on the socket. That way the most cpu is saved when there are no connections, and everything is asynchronous (including the dns). From what I can see in the enet code -- enet_host_service() and enet_socket_wait(), the way to replace the main loop would be something like this, for reading:<br>




<br>// basically set a callback for when data is available for reading<br>event_set(&amp;evinfo, socket, EV_READ | EV_PERSIST, readcb, NULL);<br>event_add(&amp;evinfo, NULL);<br><br>void readcb(...) { // handle incoming data. the code is pasted<br>





        if (event != NULL)<br>    {<br>        event -&gt; type = ENET_EVENT_TYPE_NONE;<br>        event -&gt; peer = NULL;<br>        event -&gt; packet = NULL;<br><br>        switch (enet_protocol_dispatch_incoming_commands (host, event))<br>




        {<br>        case 1:<br>            return 1;<br><br>        case -1:<br>            perror (&quot;Error dispatching incoming packets&quot;);<br><br>            return -1;<br><br>        default:<br>            break;<br>




        }<br>    }<br>
}<br>
<br>
(and something similar for writing)<br><br>So basically, it would mean replacing enet_host_service() in the program with the libevent setup.<br><br>The reason I&#39;m doing this is because libevent also provides me with async DNS, http server/client code, and I&#39;ve already written IRC client code. This would also make frogmod modular, able to easily support other enet based servers (like blood frontier).<br>



<br>My questions are:<br>1. Is this code the good way to go about it? Basically with libevent you add some fds for reading and some for writing, then enter its loop, from where it dispatches.<br>2. What would you recommend instead?<br>



<br>
<br></div></div>_______________________________________________<br>
ENet-discuss mailing list<br>
<a href="mailto:ENet-discuss@cubik.org" target="_blank">ENet-discuss@cubik.org</a><br>
<a href="http://lists.cubik.org/mailman/listinfo/enet-discuss" target="_blank">http://lists.cubik.org/mailman/listinfo/enet-discuss</a><br>
<br></blockquote></div><br>
<br>_______________________________________________<br>
ENet-discuss mailing list<br>
<a href="mailto:ENet-discuss@cubik.org">ENet-discuss@cubik.org</a><br>
<a href="http://lists.cubik.org/mailman/listinfo/enet-discuss" target="_blank">http://lists.cubik.org/mailman/listinfo/enet-discuss</a><br>
<br></blockquote></div><br>