G&#39;day,<div><br></div><div>During development we found an issue with the way ENet handles the disconnect command. We generally service our host 30 times per second (in step with our framerate), however, during a level load there&#39;s an unavoidable second or two where the game finalises some data - we found that, if the host disconnected the client during this time, the client would never be notified of the disconnect - the peer representing the host on the client machine would simply become reset.</div>
<div><br></div><div>After some investigation, we found that this was happening:</div><div><br></div><div>- Client goes into its 1-2 second deadstate;</div><div>- Host issues a ENET_PROTOCOL_COMMAND_DISCONNECT command to the client;</div>
<div>- Host times out the command, having not received an acknowledgement, and resends it (this can happen easily in a LAN environment where ping is low);</div><div>- Client wakes up from its deadstate and starts to call enet_host_service;</div>
<div>- Client receives the initial disconnect command, and enet_protocol_handle_disconnect transitions to state ENET_PEER_STATE_ACKNOWLEDGING_DISCONNECT;</div><div>- Client immediately receives the second disconnect command, and enet_protocol_handle_disconnect calls enet_peer_reset -- the client is then not notified of the disconnection.</div>
<div><br></div><div>Our solution was to not reset the peer if the peer is in the acknowledging disconnect state -- changing:</div><div><br></div><div>    if (peer -&gt; state != ENET_PEER_STATE_CONNECTED &amp;&amp; peer -&gt; state != ENET_PEER_STATE_DISCONNECT_LATER)</div>
<div><br></div><div>to:</div><div><br></div><div><div>    if (peer -&gt; state != ENET_PEER_STATE_CONNECTED &amp;&amp; peer -&gt; state != ENET_PEER_STATE_DISCONNECT_LATER</div><div>      &amp;&amp; peer -&gt; state != ENET_PEER_STATE_ACKNOWLEDGING_DISCONNECT)</div>
<div><br></div><div>solved our issue.</div><div><br></div><div>I thought I would share this, as it was tricky to track down, and there&#39;s also the possibility that I&#39;m Doin&#39; It Wrong and there&#39;s another solution that I have overlooked... J</div>
<div><br></div><div>Regards,</div><div><br></div><div>- Blair</div></div>