[ENet-discuss] enet_host_service() never returns > 0.
Mike Diehl
mdiehl at diehlnet.com
Sun Jul 3 23:37:16 PDT 2011
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. ;^)
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.
The applicable server code is:
=====================================================================
while (1) {
while (enet_host_service(server, &event, 5000) > 0) {
switch (event.type) {
case ENET_EVENT_TYPE_CONNECT:
printf("connect\n");
break;
case ENET_EVENT_TYPE_RECEIVE:
printf("receive\n");
break;
case ENET_EVENT_TYPE_DISCONNECT:
printf("disconnect\n");
break;
default:
break;
}
}
printf("Tick tock.\n");
}
=====================================================================
All it prints is Tick Tock, over and over again.
The client code is fairly straightforward:
=====================================================================
client = enet_host_create(NULL, 1, 2, 5760/8, 1440/8);
if (client == NULL) {
printf("Could not create client.\n");
return 0;
}
enet_address_set_host(&address, HOST);
address.port = PORT;
peer = enet_host_connect(client, &address, 2, 0);
if (peer == NULL) {
printf("Could not connect to server\n");
return 0;
}
if (enet_host_service(client, &event, 5000) > 0 &&
event.type == ENET_EVENT_TYPE_CONNECT) {
printf("Connection to %s succeeded.\n", HOST);
} else {
enet_peer_reset(peer);
printf("Could not connect to %s.\n", HOST);
return 0;
}
=====================================================================
This code indicates that it was able to connect to the server.
What am I missing? TIA.
--
Take care and have fun,
Mike Diehl.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cubik.org/pipermail/enet-discuss/attachments/20110704/c6db0486/attachment.html>
More information about the ENet-discuss
mailing list