<!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> </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> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=907333621-18042006></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=907333621-18042006>#include
<stdio.h><BR>#include <conio.h><BR>#include
<process.h><BR>#include "enet\enet.h"</SPAN></FONT></DIV>
<DIV> </DIV><FONT face=Arial size=2><SPAN class=907333621-18042006>
<DIV><BR>ENetHost * server;</DIV>
<DIV> </DIV>
<DIV>void startserver(int UDPport)<BR>{</DIV>
<DIV> </DIV>
<DIV> ENetAddress address;</DIV>
<DIV> </DIV>
<DIV> /* Bind the server to the default
localhost. */<BR> /* A specific host
address can be specified by */<BR>
enet_address_set_host (& address, "localhost");</DIV>
<DIV> </DIV>
<DIV> address.host = ENET_HOST_ANY;<BR> /*
Bind the server to port 1234. */<BR> address.port =
UDPport;</DIV>
<DIV> </DIV>
<DIV> server = enet_host_create (& address /* the address
to bind the server host to */,
<BR>
32 /* allow up to 32 clients and/or outgoing
connections
*/,<BR>
0 /* assume any amount of incoming bandwidth
*/,<BR>
0 /* assume any amount of outgoing bandwidth
*/);<BR> if (server == NULL)<BR>
{<BR> fprintf (stderr,
<BR>
"An error occurred while trying to create an ENet server
host.\n");<BR> exit
(EXIT_FAILURE);<BR> }</DIV>
<DIV> </DIV>
<DIV>}</DIV>
<DIV> </DIV>
<DIV>void stopserver()<BR>{<BR>
enet_host_destroy(server);<BR>}</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>void evtThread(void *p)<BR>{<BR> ENetEvent
event;<BR> <BR> /* Wait up to 1000
milliseconds for an event. */<BR> int rc = enet_host_service (server, &
event, 1000);<BR> while (rc >= 0)<BR>
{<BR> cprintf("Event rc %d\r\n", rc);<BR> if (rc >
0)<BR> {<BR> switch
(event.type)<BR> {<BR> case
ENET_EVENT_TYPE_CONNECT:<BR> printf ("A new client
connected from %x:%u.\n", <BR> event.peer
-> address.host,<BR> event.peer ->
address.port);</DIV>
<DIV> </DIV>
<DIV> /* Store any relevant client information here.
*/<BR> event.peer -> data = "Client
information";</DIV>
<DIV> </DIV>
<DIV> break;</DIV>
<DIV> </DIV>
<DIV> case
ENET_EVENT_TYPE_RECEIVE:<BR> printf ("A packet of
length %u containing %s was received from %s on channel
%u.\n",<BR> event.packet ->
dataLength,<BR> event.packet ->
data,<BR> event.peer ->
data,<BR> event.channelID);</DIV>
<DIV> </DIV>
<DIV> /* Clean up the packet now that we're done
using it. */<BR> enet_packet_destroy
(event.packet);<BR>
<BR> break;<BR>
<BR> case
ENET_EVENT_TYPE_DISCONNECT:<BR> printf ("%s
disconected.\n", event.peer -> data);</DIV>
<DIV> </DIV>
<DIV> /* Reset the peer's client information. */</DIV>
<DIV> </DIV>
<DIV> event.peer -> data =
NULL;<BR> }<BR> }<BR> rc =
enet_host_service (server, & event, 1000);<BR>
}<BR>}</DIV>
<DIV> </DIV>
<DIV>int main (int argc, char * argv[]) <BR>{<BR> if
(enet_initialize () != 0)<BR>
{<BR> fprintf (stderr, "An error
occurred while initializing
ENet.\n");<BR> return
EXIT_FAILURE;<BR> }<BR> atexit
(enet_deinitialize);<BR> <BR> startserver(atoi(argv[1]));<BR> _beginthread(evtThread,
300, NULL);<BR> getch();<BR> stopserver();<BR> return
0;<BR>}<BR></SPAN></FONT></DIV></BODY></HTML>