You need to have a similar loop like the server in order for the client to receive the packet. enet_host_service should be called often since that's the only way for either the client or the server to update.<br><br><div class="gmail_quote">
On Mon, Jul 4, 2011 at 7:37 AM, Mike Diehl <span dir="ltr"><<a href="mailto:mdiehl@diehlnet.com">mdiehl@diehlnet.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
 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><font color="#888888">
Mike Diehl.


</font><br>_______________________________________________<br>
ENet-discuss mailing list<br>
<a href="mailto:ENet-discuss@cubik.org">ENet-discuss@cubik.org</a><br>
<a href="http://lists.cubik.org/mailman/listinfo/enet-discuss" target="_blank">http://lists.cubik.org/mailman/listinfo/enet-discuss</a><br>
<br></blockquote></div><br>