<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;
        color:black;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor=white lang=DE link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Hi !<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Something related was bugging me some time as well. When you try
to connect, after a while, if successful, you get a </span><span lang=EN-US
style='font-size:10.0pt;font-family:"Courier New";color:windowtext'>ENET_EVENT_TYPE_CONNECT,
but you never get a notification when the connection doesn’t get established.
Maybe enet keeps trying infinitly itself? I “solved” the issue for me by
checking if some selfdefined timeout is passed and the call enet_host_destroy. Creating
a new one afterwards and trying to connect again works.<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
color:windowtext'><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
color:windowtext'>Best regards<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
color:windowtext'> Marc<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<div>
<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'>
<p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:
"Tahoma","sans-serif";color:windowtext'>From:</span></b><span lang=EN-US
style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext'>
enet-discuss-bounces@cubik.org [mailto:enet-discuss-bounces@cubik.org] <b>On
Behalf Of </b>William Brandt<br>
<b>Sent:</b> Donnerstag, 18. Juni 2009 19:08<br>
<b>To:</b> Discussion of the ENet library<br>
<b>Subject:</b> Re: [ENet-discuss] ENetPeer structure when reconnecting<o:p></o:p></span></p>
</div>
</div>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Ruud van Gaal wrote: <o:p></o:p></p>
<pre>This all sounds familiar. I have this connection scheme with the following<o:p></o:p></pre><pre>properties:<o:p></o:p></pre><pre>- the server may not be online yet<o:p></o:p></pre><pre>- the client attempts a connection every second or 2, to see if the server<o:p></o:p></pre><pre>is already alive<o:p></o:p></pre><pre>- I only want 1 connection (client<->server)<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>I have a C++ wrapper (class QNClient) which only tracks 1 peer. This client<o:p></o:p></pre><pre>class is legacy and only represents 1 link to a server (class QNServer).<o:p></o:p></pre><pre>For repeated connection attempts, this was no problem in the past (without<o:p></o:p></pre><pre>ENet); I sent out some kind of CONNECT packet, and if something came back,<o:p></o:p></pre><pre>it was connected.<o:p></o:p></pre><pre>With the ENet peer, I start an enet_host_connect() with every connection<o:p></o:p></pre><pre>attempt. If I create an ENet host with only 1 peer, I run out of peers after<o:p></o:p></pre><pre>this first connect attempt.<o:p></o:p></pre><pre>It's a bit awkward, since if I allow more peers in the ENet host, multiple<o:p></o:p></pre><pre>peers may connect succesfully. I'll have to drop the surplus of connections<o:p></o:p></pre><pre>once the server comes up and it turns out I get multiple<o:p></o:p></pre><pre>ENET_EVENT_TYPE_CONNECT events.<o:p></o:p></pre><pre>It seems to work though with 1 peer, I just get a lot of 'out of peer' error<o:p></o:p></pre><pre>when trying enet_host_connect(). I haven't tried resetting the peer; I don't<o:p></o:p></pre><pre>think I want to since a connect reply may still be incoming and I'd rather<o:p></o:p></pre><pre>handle that as usual.<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>Ruud<o:p></o:p></pre><pre><o:p> </o:p></pre><pre><o:p> </o:p></pre><pre> <o:p></o:p></pre>
<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>-----Oorspronkelijk bericht-----<o:p></o:p></pre><pre>Van: <a
href="mailto:enet-discuss-bounces@cubik.org">enet-discuss-bounces@cubik.org</a> <o:p></o:p></pre><pre>[<a
href="mailto:enet-discuss-bounces@cubik.org">mailto:enet-discuss-bounces@cubik.org</a>] Namens Daniel Aquino<o:p></o:p></pre><pre>Verzonden: Thursday, June 18, 2009 18:13<o:p></o:p></pre><pre>Aan: Discussion of the ENet library<o:p></o:p></pre><pre>Onderwerp: Re: [ENet-discuss] ENetPeer structure when reconnecting<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>Perhaps as I said you ran out of peers... So until the <o:p></o:p></pre><pre>callback stack was finished that peer wouldn't be free yet...<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>On Wed, Jun 17, 2009 at 11:23 PM, William <o:p></o:p></pre><pre>Brandt<a
href="mailto:taekvideo@gmail.com"><taekvideo@gmail.com></a> wrote:<o:p></o:p></pre><pre> <o:p></o:p></pre>
<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>Daniel Aquino wrote:<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>>From what i know there is no deleting. I believe enet <o:p></o:p></pre><pre> <o:p></o:p></pre></blockquote>
<pre>will clean up<o:p></o:p></pre><pre> <o:p></o:p></pre>
<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>the peer after it has told you about the event and you have had a <o:p></o:p></pre><pre>chance to react. And the connection function will return a <o:p></o:p></pre><pre> <o:p></o:p></pre></blockquote>
<pre>new peer <o:p></o:p></pre><pre> <o:p></o:p></pre>
<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>with no way to re-use the existing peer that I know of... <o:p></o:p></pre><pre> <o:p></o:p></pre></blockquote>
<pre>Which does <o:p></o:p></pre><pre> <o:p></o:p></pre>
<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>confuse me a bit in the case of attempting to make a new connection <o:p></o:p></pre><pre>inside of the disconnection event when there is no more <o:p></o:p></pre><pre> <o:p></o:p></pre></blockquote>
<pre>peers left...<o:p></o:p></pre><pre> <o:p></o:p></pre>
<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>I don't know if in that case it would still consider that peer as <o:p></o:p></pre><pre>valid resulting in the inability to form a new connection or if it <o:p></o:p></pre><pre>would end up using that same peer destroying data inside of it that <o:p></o:p></pre><pre>you may still need... So I copied any data I needed from the peer<o:p></o:p></pre><pre>object before making the new connection just in case... I guess<o:p></o:p></pre><pre>these questions could be solved easily by looking into the <o:p></o:p></pre><pre> <o:p></o:p></pre></blockquote>
<pre>enet code <o:p></o:p></pre><pre> <o:p></o:p></pre>
<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>or setting the peer count to 1 and doing some testing...<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>On Wed, Jun 17, 2009 at 2:47 PM, William <o:p></o:p></pre><pre> <o:p></o:p></pre></blockquote>
<pre>Brandt<a href="mailto:taekvideo@gmail.com"><taekvideo@gmail.com></a> wrote:<o:p></o:p></pre><pre> <o:p></o:p></pre>
<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre><o:p> </o:p></pre><pre>When a user is disconnected from the server and is <o:p></o:p></pre><pre> <o:p></o:p></pre></blockquote>
<pre>reconnecting, do I <o:p></o:p></pre><pre> <o:p></o:p></pre>
<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>need to get a new ENetPeer object (from the enet_host_connect() <o:p></o:p></pre><pre>function), or is it possible to use the same one to <o:p></o:p></pre><pre> <o:p></o:p></pre></blockquote>
<pre>reconnect? Also, <o:p></o:p></pre><pre> <o:p></o:p></pre>
<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>if I have to get a new one, do I need to delete the old one (& how)?<o:p></o:p></pre><pre> <o:p></o:p></pre></blockquote>
</blockquote>
<pre>...<o:p></o:p></pre><pre> <o:p></o:p></pre>
<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'>
<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>well what I'm doing now seems to be working...<o:p></o:p></pre><pre>the main problem I was having was that enet_host_connect() was <o:p></o:p></pre><pre>returning NULL when I tried to reconnect. It seems I had to <o:p></o:p></pre><pre>explicitly call<o:p></o:p></pre><pre>enet_peer_reset() on the old peer object before I reconnect <o:p></o:p></pre><pre> <o:p></o:p></pre></blockquote>
<pre>and get a <o:p></o:p></pre><pre> <o:p></o:p></pre>
<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>new peer object.<o:p></o:p></pre><pre> <o:p></o:p></pre></blockquote>
</blockquote>
<pre><o:p> </o:p></pre><pre>_______________________________________________<o:p></o:p></pre><pre>ENet-discuss mailing list<o:p></o:p></pre><pre><a
href="mailto:ENet-discuss@cubik.org">ENet-discuss@cubik.org</a><o:p></o:p></pre><pre><a
href="http://lists.cubik.org/mailman/listinfo/enet-discuss">http://lists.cubik.org/mailman/listinfo/enet-discuss</a><o:p></o:p></pre><pre><o:p> </o:p></pre><pre> <o:p></o:p></pre>
<p class=MsoNormal>You should add a 5000ms delay when you call
enet_host_service() to check for connect events after calling
enet_host_connect(). Then if you don't get a response you can safely
assume that the server isn't going to respond and reset the peer then try
again.<o:p></o:p></p>
</div>
</body>
</html>