<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 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
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;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></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 lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>We currently use ENet to provide an internal networking layer for a C++ multithreaded concurrency framework.  ENet is well-conceived, and has all speed, simplicity, functionality, and sensible design we were looking for.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>As others have pointed out, there is a limitation with enet_host_service( ) blocking on receive when you have things to send.  Our current coping solution is to dynamically reduce the receive time-out to 0 or 1 msec when host activity is active, lengthening to 20 msecs when quiescent.  This approach causes a 20 msec delay for the first send( ) in a series, and generates more thread activity than desired for quiescent host threads.  No adjustments to this can improve the situation.<o:p></o:p></p><p class=MsoNormal>                              <o:p></o:p></p><p class=MsoNormal>A better solution others have mentioned involves making (only for Win32) modifications to the enet_socket_wait function to allow waiting on socket send and receive, as well as a “cancel wait” event object (using WSAEventSelect, and WSAWaitForMultipleObjects).  Then add an additional function (enet_socket_cancel_wait) that signals the “cancel wait” event object and wakes the network thread.  From there, the enet_host_service function immediately returns with a timeout event to process the send command.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>But we propose a simpler solution, to have enet_socket_cancel_wait( ) sense when a blocking-on-receive is occurring, then send a local administrative packet through that socket to release it, which when received returns an ENET_EVENT_TYPE_CANCEL_TIMEOUT.  This "send" would be triggerable by any thread, and would quickly ignore additional redundant requests that occur while in flight.  The big advantage of this approach is that the existing receive logic runs unchanged, without complicating it beyond recoginizing the admin packet to return a different event type.  <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>A new ENet function or option would likely be necessary, to enable this feature when desired, so that existing message loops would remain unaffected.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I would be most interested in knowing the feasibility of this proposed approach, should we consider implementing it ourselves.  However, we would much prefer to wait for an official ENet build that solves this pressing issue.  Are there plans to resolve this limitation.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Thanks,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Chris Cochran<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>