<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2800.1491" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial size=2><SPAN class=907333621-18042006>Hi 
all,</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=907333621-18042006></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><SPAN class=907333621-18042006>Can some one take a 
look at my simple testing code? I am not getting any events at all. I use a 
simple client code connect to it. The client says connection is sucessful but 
there is no event generated on the server.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=907333621-18042006></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=907333621-18042006></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><SPAN class=907333621-18042006>#include 
&lt;stdio.h&gt;<BR>#include &lt;conio.h&gt;<BR>#include 
&lt;process.h&gt;<BR>#include "enet\enet.h"</SPAN></FONT></DIV>
<DIV>&nbsp;</DIV><FONT face=Arial size=2><SPAN class=907333621-18042006>
<DIV><BR>ENetHost * server;</DIV>
<DIV>&nbsp;</DIV>
<DIV>void startserver(int UDPport)<BR>{</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; ENetAddress address;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; /* Bind the server to the default 
localhost.&nbsp;&nbsp;&nbsp;&nbsp; */<BR>&nbsp;&nbsp;&nbsp; /* A specific host 
address can be specified by&nbsp;&nbsp; */<BR>&nbsp;&nbsp;&nbsp; 
enet_address_set_host (&amp; address, "localhost");</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; address.host = ENET_HOST_ANY;<BR>&nbsp;&nbsp;&nbsp; /* 
Bind the server to port 1234. */<BR>&nbsp;&nbsp;&nbsp; address.port = 
UDPport;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; server = enet_host_create (&amp; address /* the address 
to bind the server host to */, 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
32&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* allow up to 32 clients and/or outgoing 
connections 
*/,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* assume any amount of incoming bandwidth 
*/,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* assume any amount of outgoing bandwidth 
*/);<BR>&nbsp;&nbsp;&nbsp; if (server == NULL)<BR>&nbsp;&nbsp;&nbsp; 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fprintf (stderr, 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
"An error occurred while trying to create an ENet server 
host.\n");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit 
(EXIT_FAILURE);<BR>&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;</DIV>
<DIV>}</DIV>
<DIV>&nbsp;</DIV>
<DIV>void stopserver()<BR>{<BR>&nbsp;&nbsp;&nbsp; 
enet_host_destroy(server);<BR>}</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>void evtThread(void *p)<BR>{<BR>&nbsp;&nbsp;&nbsp; ENetEvent 
event;<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; /* Wait up to 1000 
milliseconds for an event. */<BR>&nbsp;int rc = enet_host_service (server, &amp; 
event, 1000);<BR>&nbsp;&nbsp;&nbsp; while (rc &gt;= 0)<BR>&nbsp;&nbsp;&nbsp; 
{<BR>&nbsp;&nbsp;cprintf("Event rc %d\r\n", rc);<BR>&nbsp;&nbsp;if (rc &gt; 
0)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;switch 
(event.type)<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;case 
ENET_EVENT_TYPE_CONNECT:<BR>&nbsp;&nbsp;&nbsp;&nbsp;printf ("A new client 
connected from %x:%u.\n", <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;event.peer 
-&gt; address.host,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;event.peer -&gt; 
address.port);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;/* Store any relevant client information here. 
*/<BR>&nbsp;&nbsp;&nbsp;&nbsp;event.peer -&gt; data = "Client 
information";</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;break;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;case 
ENET_EVENT_TYPE_RECEIVE:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf ("A packet of 
length %u containing %s was received from %s on channel 
%u.\n",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;event.packet -&gt; 
dataLength,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;event.packet -&gt; 
data,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;event.peer -&gt; 
data,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;event.channelID);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Clean up the packet now that we're done 
using it. */<BR>&nbsp;&nbsp;&nbsp;&nbsp;enet_packet_destroy 
(event.packet);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;break;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<BR>&nbsp;&nbsp;&nbsp;case 
ENET_EVENT_TYPE_DISCONNECT:<BR>&nbsp;&nbsp;&nbsp;&nbsp;printf ("%s 
disconected.\n", event.peer -&gt; data);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;/* Reset the peer's client information. */</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;event.peer -&gt; data = 
NULL;<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;rc = 
enet_host_service (server, &amp; event, 1000);<BR>&nbsp;&nbsp;&nbsp; 
}<BR>}</DIV>
<DIV>&nbsp;</DIV>
<DIV>int main (int argc, char * argv[]) <BR>{<BR>&nbsp;&nbsp;&nbsp; if 
(enet_initialize () != 0)<BR>&nbsp;&nbsp;&nbsp; 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fprintf (stderr, "An error 
occurred while initializing 
ENet.\n");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 
EXIT_FAILURE;<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; atexit 
(enet_deinitialize);<BR>&nbsp;<BR>&nbsp;startserver(atoi(argv[1]));<BR>&nbsp;_beginthread(evtThread, 
300, NULL);<BR>&nbsp;getch();<BR>&nbsp;stopserver();<BR>&nbsp;return 
0;<BR>}<BR></SPAN></FONT></DIV></BODY></HTML>