I'm trying to write a simple demonstration program with enet 1.3.3. The demo is mostly based on the example code snippets from the enet website, so it should have been fairly simple. ;^)<br />
<br />
The client claims to have connected successfully. A tcpdump indicates that the client sent a packet, and the server replied a few times. The server never dispatches the CONNECT event.<br />
<br />
The applicable server code is:<br />
=====================================================================<br />
while (1) {<br />
while (enet_host_service(server, &event, 5000) > 0) {<br />
switch (event.type) {<br />
case ENET_EVENT_TYPE_CONNECT:<br />
printf("connect\n");<br />
break;<br />
case ENET_EVENT_TYPE_RECEIVE:<br />
printf("receive\n");<br />
break;<br />
case ENET_EVENT_TYPE_DISCONNECT:<br />
printf("disconnect\n");<br />
break;<br />
default:<br />
break;<br />
}<br />
}<br />
<br />
printf("Tick tock.\n");<br />
}<br />
=====================================================================<br />
<br />
All it prints is Tick Tock, over and over again.<br />
<br />
The client code is fairly straightforward:<br />
=====================================================================<br />
client = enet_host_create(NULL, 1, 2, 5760/8, 1440/8);<br />
<br />
if (client == NULL) {<br />
printf("Could not create client.\n");<br />
return 0;<br />
}<br />
<br />
enet_address_set_host(&address, HOST);<br />
address.port = PORT;<br />
<br />
peer = enet_host_connect(client, &address, 2, 0);<br />
<br />
if (peer == NULL) {<br />
printf("Could not connect to server\n");<br />
return 0;<br />
}<br />
<br />
if (enet_host_service(client, &event, 5000) > 0 &&<br />
event.type == ENET_EVENT_TYPE_CONNECT) {<br />
<br />
printf("Connection to %s succeeded.\n", HOST);<br />
} else {<br />
enet_peer_reset(peer);<br />
printf("Could not connect to %s.\n", HOST);<br />
return 0;<br />
}<br />
=====================================================================<br />
This code indicates that it was able to connect to the server.<br />
What am I missing? TIA.<hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;"><br />
Take care and have fun,<br />
Mike Diehl.