<div dir="ltr">Happy to help. ENET rocks! :-)<div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 15, 2014 at 9:29 PM, Laftur Jeremy <span dir="ltr"><<a href="mailto:laftur.jeremy@gmail.com" target="_blank">laftur.jeremy@gmail.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Oh, I see now. This crossed my mind, that the client might should not<br>
exit immediately when it fires the connect event, so at one point I<br>
had the client sleep for 10 seconds before breaking to give the server<br>
time to acknowledge.<br>
I see now why that didn't work. ENet needs me to continue to call<br>
enet_host_service to complete the connection.<br>
<br>
Thank you so much, Pablo! You're gold. :D<br>
<br>
On Mon, Dec 15, 2014 at 3:15 PM, Pablo de Heras Ciechomski<br>
<div class="HOEnZb"><div class="h5"><<a href="mailto:pablo.deheras@gmail.com">pablo.deheras@gmail.com</a>> wrote:<br>
> Ok so let's dance ;-) I downloaded your code, compiled and ran it. Indeed as<br>
> you have it you exit immediately upon a connect event on the client side,<br>
> this does not mean the server yet received your connect and immediately you<br>
> exit. I removed the break here and it works as it should. That is the server<br>
> gets the connect event "immediately".<br>
><br>
> ENetEvent event;<br>
> for(;;) {<br>
> int ret = enet_host_service(client, &event, 1000);<br>
> if(ret < 0) throw std::runtime_error("enet_host_service failed");<br>
> if(event.type == ENET_EVENT_TYPE_NONE) {<br>
> std::cout << "ENET_NONE\n";<br>
> }<br>
> else if(event.type == ENET_EVENT_TYPE_CONNECT) {<br>
> std::cout << "ENET_CONNECT\n";<br>
> // Sending a packet causes the connection to be recognized on the server<br>
> end. Uncomment the following 3 lines to observe the behavior.<br>
> //ENetPacket * packet = enet_packet_create("a", 1,<br>
> ENET_PACKET_FLAG_RELIABLE);<br>
> //enet_peer_send(peer, 0, packet);<br>
> //enet_host_flush(client);<br>
> I changed this removing the break -> //break;<br>
> }<br>
> else if(event.type == ENET_EVENT_TYPE_RECEIVE) {<br>
> std::cout << "ENET_RECEIVE\n";<br>
> }<br>
> else if(event.type == ENET_EVENT_TYPE_DISCONNECT) {<br>
> throw std::runtime_error("Connection failed");<br>
> }<br>
> }<br>
><br>
> On Mon, Dec 15, 2014 at 8:50 PM, Laftur Jeremy <<a href="mailto:laftur.jeremy@gmail.com">laftur.jeremy@gmail.com</a>><br>
> wrote:<br>
>><br>
>> Here is the new client.cpp:<br>
>><br>
>> <a href="http://dpaste.com/3VWDWK7.txt" target="_blank">http://dpaste.com/3VWDWK7.txt</a><br>
>><br>
>> I added enet_host_flush on line 14, immediately after<br>
>> enet_host_connect and the check for a NULL peer, like you have in your<br>
>> code example, but the server still does not fire the connect event.<br>
>><br>
>> Could you confirm that the platform tests you performed used the code<br>
>> I provided and not your interpretation of my code? I am running this<br>
>> on ArchLinux, kernel version 3.17.6-1, ENet version 1.3.12-1<br>
>><br>
>> On Mon, Dec 15, 2014 at 1:57 PM, Pablo de Heras Ciechomski<br>
>> <<a href="mailto:pablo.deheras@gmail.com">pablo.deheras@gmail.com</a>> wrote:<br>
>> > Ah I see now in your source. You have to do the host_flush like I have<br>
>> > provided here after the enet_host_connect on the client and not inside<br>
>> > the<br>
>> > event loop itself. What you did is backwards logic as you are waiting<br>
>> > for an<br>
>> > event to force that event. The host service loop is just an event pump.<br>
>> ><br>
>> > Hope that clears it up.<br>
>> ><br>
>> > Pablo<br>
>> ><br>
>> > On Mon, Dec 15, 2014 at 7:45 PM, Pablo de Heras Ciechomski<br>
>> > <<a href="mailto:pablo.deheras@gmail.com">pablo.deheras@gmail.com</a>> wrote:<br>
>> >><br>
>> >> Indeed that is strange. I have correct behaviour on 3 platforms<br>
>> >> Windows,<br>
>> >> Mac and iPad using the flush command. Meaning that I immediately get a<br>
>> >> connect event on the server upon the flush and do not have to send a<br>
>> >> packet<br>
>> >> or otherwise to force it from the client.<br>
>> >><br>
>> >>   ENetAddress address;<br>
>> >>   enet_address_set_host(&address,m_peerAddress.m_str);<br>
>> >>   address.port=m_peerPort;<br>
>> >>   m_peer=enet_host_connect(m_host,&address,2,0);<br>
>> >>   if (m_peer==0)<br>
>> >>   {<br>
>> >>     return;<br>
>> >>   }<br>
>> >>   enet_host_flush(m_host);<br>
>> >><br>
>> >> Pablo<br>
>> >><br>
>> >> On Mon, Dec 15, 2014 at 7:38 PM, Laftur Jeremy<br>
>> >> <<a href="mailto:laftur.jeremy@gmail.com">laftur.jeremy@gmail.com</a>><br>
>> >> wrote:<br>
>> >>><br>
>> >>> Pablo, it is my understanding that enet_host_service also would do<br>
>> >>> this, but to test it, I called enet_host_flush immediately after<br>
>> >>> enet_host_connect in the client app. The result is the same. The<br>
>> >>> server does not fire the connect event unless the client sends an ENet<br>
>> >>> packet after connecting.<br>
>> >>> Maybe i misunderstand you. What do you mean by "The behaviour that you<br>
>> >>> are seeking will be the same."?<br>
>> >>><br>
>> >>> On Mon, Dec 15, 2014 at 3:35 AM, Pablo de Heras Ciechomski<br>
>> >>> <<a href="mailto:pablo.deheras@gmail.com">pablo.deheras@gmail.com</a>> wrote:<br>
>> >>> > Or you simply do an enet_host_flush(theHost) in your client app,<br>
>> >>> > which<br>
>> >>> > will<br>
>> >>> > force the connect event. The behaviour that you are seeking will be<br>
>> >>> > the<br>
>> >>> > same.<br>
>> >>> ><br>
>> >>> > Pablo<br>
>> >>> ><br>
>> >>> > On Mon, Dec 15, 2014 at 5:51 AM, Laftur Jeremy<br>
>> >>> > <<a href="mailto:laftur.jeremy@gmail.com">laftur.jeremy@gmail.com</a>><br>
>> >>> > wrote:<br>
>> >>> >><br>
>> >>> >> I'm new to ENet, and I'm excited to use it in my projects. I made<br>
>> >>> >> simple server and client programs to test it out and to make sure I<br>
>> >>> >> understood how to use it.<br>
>> >>> >><br>
>> >>> >> You may follow this link to view my server code:<br>
>> >>> >><br>
>> >>> >> <a href="http://dpaste.com/2JW0DYE.txt" target="_blank">http://dpaste.com/2JW0DYE.txt</a><br>
>> >>> >><br>
>> >>> >> ... And the client code is here:<br>
>> >>> >><br>
>> >>> >> <a href="http://dpaste.com/1CKC6DC.txt" target="_blank">http://dpaste.com/1CKC6DC.txt</a><br>
>> >>> >><br>
>> >>> >><br>
>> >>> >> The client program appears to function as expected, but the server<br>
>> >>> >> program isn't firing the connect event for some reason. After<br>
>> >>> >> combing<br>
>> >>> >> the documentation and tutorials for more time than I'd care to<br>
>> >>> >> admit,<br>
>> >>> >> I finally decided to try to send a packet from the client to see if<br>
>> >>> >> that did anything.<br>
>> >>> >><br>
>> >>> >> It turns out that the server program waits to fire the connect<br>
>> >>> >> event<br>
>> >>> >> until the client actually sends a packet over the new connection.<br>
>> >>> >> You<br>
>> >>> >> may observe this behavior by uncommenting the indicated lines in<br>
>> >>> >> the<br>
>> >>> >> client program source.<br>
>> >>> >><br>
>> >>> >> I would first like to know if my example programs exhibit the same<br>
>> >>> >> behavior for anyone else. If so, I would like to know if the<br>
>> >>> >> behavior<br>
>> >>> >> is intended, and if so, I would like to know the reason for that,<br>
>> >>> >> and<br>
>> >>> >> I would suggest that the documentation provide some advice on this,<br>
>> >>> >> as<br>
>> >>> >> it has confused me greatly. Thanks so much for any help anyone can<br>
>> >>> >> provide. You're the gold of the Internet just for being available<br>
>> >>> >> to<br>
>> >>> >> help.<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>
>> >>> ><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>
>> >>> _______________________________________________<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>
>> >><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>
>> _______________________________________________<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>
><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>
_______________________________________________<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></div></div></blockquote></div>
</div></div>