<font size=2 face="sans-serif">I've investigated this further and is seems
like the problem occurs when the server side gets two connect commands,
</font><font size=2>ENET_PROTOCOL_COMMAND_CONNECT</font><font size=2 face="sans-serif">
from the same client without any disconnect in between. The ENet host at
the server will in that case get two peers with the exact same address
and port. After a while one of them will get a timeout, and that timeout
is what triggers the strange </font><font size=2>ENET_EVENT_TYPE_DISCONNECT</font><font size=2 face="sans-serif">.
Our application code at the server side interprets this as a connection
loss, but on the client side it is still connected since we have that other
peer still up and running and responding.</font>
<br>
<br><font size=2 face="sans-serif">I've solved this by letting the application
code on the server do a reset on the current peer when a new is received
with the same address and port.<br>
<br>
</font><font size=2 face="Arial"><br>
Best regards, </font>
<table>
<tr valign=top>
<td>
<td>
<td>
<td>
<tr valign=top>
<td colspan=4><font size=3 color=#00a1e0 face="Arial"><b><i>Kristin Nielsen</i></b></font><font size=1 face="Arial">
</font><font size=1 face="Arial"><b><i><br>
Software Developer LHD Applications</i></b></font><font size=1 face="Arial">
</font><font size=1 face="Arial"><b><i><br>
Rocktec Division</i></b></font><font size=1 face="Arial"> </font>
<hr noshade>
<tr valign=top>
<td colspan=4><font size=1 color=#2f2f2f face="Arial">Atlas Copco Rock
Drills AB </font>
<tr valign=top>
<td><font size=1 color=#00a1e0 face="Arial"><b>Address: </b></font>
<td><font size=1 color=#2f2f2f face="Arial">Klerkgatan 21 <br>
701 91 Örebro <br>
Sweden <br>
</font>
<td><font size=1 color=#00a1e0 face="Arial"><b>Phone:</b> </font>
<td><font size=1 color=#2f2f2f face="Arial">+46 019 768 25 85 </font>
<tr valign=top>
<td>
<td>
<td>
<td>
<tr valign=top>
<td><font size=1 color=#00a1e0 face="Arial"><b>E-mail: </b></font>
<td><a href=mailto:kristin.nielsen@se.atlascopco.com><font size=1 color=#2f2f2f face="Arial">kristin.nielsen@se.atlascopco.com</font></a><font size=1 color=#2f2f2f face="Arial">
</font>
<td><font size=1 color=#00a1e0 face="Arial"><b>Visit us at: <br>
Follow us at:</b></font><font size=1 face="Arial"> </font>
<td><a href=http://www.atlascopco.com/ target=_blank><font size=1 color=#2f2f2f face="Arial">http://www.atlascopco.com</font></a><font size=1 color=#2f2f2f face="Arial"><i><br>
</i></font><a href=https://www.facebook.com/atlascopco target=_blank><font size=1 color=#2f2f2f face="Arial"><i>Facebook
</i></font></a><font size=1 color=#2f2f2f face="Arial">/ </font><a href=https://twitter.com/AtlasCopcoGroup target=_blank><font size=1 color=#2f2f2f face="Arial"><i>Twitter
</i></font></a><font size=1 color=#2f2f2f face="Arial">/ </font><a href="http://www.linkedin.com/company/atlas-copco" target=_blank><font size=1 color=#2f2f2f face="Arial"><i>LinkedIn
</i></font></a><font size=1 color=#2f2f2f face="Arial">/ </font><a href=http://www.youtube.com/user/atlascopcogroup target=_blank><font size=1 color=#2f2f2f face="Arial"><i>YouTube</i></font></a><font size=1 color=#2f2f2f face="Arial">
</font>
<tr>
<td colspan=2><font size=1 color=#00a1e0 face="Arial"><b>Committed to sustainable
productivity              </b></font>
<td colspan=2></table>
<br>
<table>
<tr valign=top>
<td><a href=http://www.atlascopco.com.cn/cnus/atlascopcogroup/ target=_blank></a></table>
<br>
<br>
<br>
<br>
<br><font size=1 color=#5f5f5f face="sans-serif">From:      
 </font><font size=1 face="sans-serif">kristin.nielsen@se.atlascopco.com</font>
<br><font size=1 color=#5f5f5f face="sans-serif">To:      
 </font><font size=1 face="sans-serif">enet-discuss@cubik.org</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Date:      
 </font><font size=1 face="sans-serif">2015-06-18 16:06</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Subject:    
   </font><font size=1 face="sans-serif">[ENet-discuss]
Inconsistent connection status between hosts in bad      
 network conditions</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Sent by:    
   </font><font size=1 face="sans-serif">"ENet-discuss"
<enet-discuss-bounces@cubik.org></font>
<br>
<hr noshade>
<br>
<br>
<br><font size=2 face="sans-serif">I've been investigating a system with
two Enet hosts under bad network conditions, and noticed  a spurious
disconnect at the server.</font><font size=3> <br>
</font><font size=2 face="sans-serif"><br>
I've used Enet v.1.3.13 and for simulating bad network I've used netem
with configuration "delay 100ms 100ms 5% loss random 45% corrupt 35%"</font><font size=3>
</font><font size=2 face="sans-serif"><br>
which means a delay of all packets of 100ms a random loss of 45% for all
packets and 35% of all packets are corrupt.</font><font size=3> <br>
</font><font size=2 face="sans-serif"><br>
At first, the network is good and both client and server connects to each
other, Enet reports </font><font size=2>ENET_EVENT_TYPE_CONNECT</font><font size=2 face="sans-serif">.</font><font size=3>
<br>
</font><font size=2 face="sans-serif"><br>
Then I apply the bad network and both the client and the server disconnects,
Enet reports </font><font size=2>ENET_EVENT_TYPE_DISCONNECT </font><font size=2 face="sans-serif">on
both client and server.</font><font size=3> <br>
</font><font size=2 face="sans-serif"><br>
When the bad network conditions are restored, at first, everything seems
to work fine. Enet reports </font><font size=2>ENET_EVENT_TYPE_CONNECT</font><font size=2 face="sans-serif">
 for both client and server. <br>
But then, after some second, I will get a spurios </font><font size=2>ENET_EVENT_TYPE_DISCONNECT
</font><font size=2 face="sans-serif">on the server side only. The client
still thinks everything is up and running.</font><font size=3> </font><font size=2 face="sans-serif"><br>
And I'm stuck in a state that I can only get out from by restarting one
of the applications(either the server or the client doesn't matter)</font><font size=3>
</font><font size=2 face="sans-serif"><br>
This happens almost everytime.</font><font size=3> <br>
</font><font size=2 face="sans-serif"><br>
I have also noted that if I apply really bad network, for example a random
loss of 95% of all packets, and the restore. Then, I havn't seen this strange
disconnect.</font><font size=2 face="Arial"><br>
<br>
Best regards, </font>
<table>
<tr valign=top>
<td>
<td>
<td>
<td>
<tr valign=top>
<td colspan=4><font size=3 color=#00a1e0 face="Arial"><b><i>Kristin Nielsen</i></b></font><font size=1 face="Arial">
<b><i><br>
Software Developer LHD Applications</i></b> <b><i><br>
Rocktec Division</i></b> </font>
<hr noshade>
<tr valign=top>
<td colspan=4><font size=1 color=#2f2f2f face="Arial">Atlas Copco Rock
Drills AB </font>
<tr valign=top>
<td><font size=1 color=#00a1e0 face="Arial"><b>Address: </b></font>
<td><font size=1 color=#2f2f2f face="Arial">Klerkgatan 21 <br>
701 91 Örebro <br>
Sweden </font>
<td><font size=1 color=#00a1e0 face="Arial"><b>Phone:</b> </font>
<td><font size=1 color=#2f2f2f face="Arial">+46 019 768 25 85 </font>
<tr valign=top>
<td>
<td>
<td>
<td>
<tr valign=top>
<td><font size=1 color=#00a1e0 face="Arial"><b>E-mail: </b></font>
<td><a href=mailto:kristin.nielsen@se.atlascopco.com><font size=1 color=#2f2f2f face="Arial"><u>kristin.nielsen@se.atlascopco.com</u></font></a><font size=1 color=#2f2f2f face="Arial">
</font>
<td><font size=1 color=#00a1e0 face="Arial"><b>Visit us at: <br>
Follow us at:</b></font><font size=1 face="Arial"> </font>
<td><a href=http://www.atlascopco.com/ target=_blank><font size=1 color=#2f2f2f face="Arial"><u>http://www.atlascopco.com</u></font></a><font size=3 color=blue><u><br>
</u></font><a href=https://www.facebook.com/atlascopco target=_blank><font size=1 color=#2f2f2f face="Arial"><i><u>Facebook
</u></i></font></a><font size=1 color=#2f2f2f face="Arial">/ </font><a href=https://twitter.com/AtlasCopcoGroup target=_blank><font size=1 color=#2f2f2f face="Arial"><i><u>Twitter
</u></i></font></a><font size=1 color=#2f2f2f face="Arial">/ </font><a href="http://www.linkedin.com/company/atlas-copco" target=_blank><font size=1 color=#2f2f2f face="Arial"><i><u>LinkedIn
</u></i></font></a><font size=1 color=#2f2f2f face="Arial">/ </font><a href=http://www.youtube.com/user/atlascopcogroup target=_blank><font size=1 color=#2f2f2f face="Arial"><i><u>YouTube</u></i></font></a><font size=1 color=#2f2f2f face="Arial">
</font>
<tr>
<td colspan=2><font size=1 color=#00a1e0 face="Arial"><b>Committed to sustainable
productivity              </b></font><font size=3>
</font>
<td colspan=2></table>
<br>
<table>
<tr valign=top>
<td><a href=http://www.atlascopco.com.cn/cnus/atlascopcogroup/ target=_blank></a></table>
<br><tt><font size=2>_______________________________________________<br>
ENet-discuss mailing list<br>
ENet-discuss@cubik.org<br>
</font></tt><a href="http://lists.cubik.org/mailman/listinfo/enet-discuss"><tt><font size=2>http://lists.cubik.org/mailman/listinfo/enet-discuss</font></tt></a><tt><font size=2><br>
</font></tt>
<br>