[ENet-discuss] enet_host_service() only acts on ENET_EVENT_TYPE_DISCONNECT

stu at evilx.com stu at evilx.com
Wed Sep 1 02:09:05 PDT 2004


Hi I'm very new to Enet.

I'm basically trying to build the tutorial and am having a weird problem.
My server is only responding to  ENET_EVENT_TYPE_DISCONNECT
events....

The client thinks it connected ok, but the server never reacts 
to/generates connect events or receive events, however when I shutdown 
the client app I get a disconnect event on the server.

What am I screwing up?


here's the server event handling code:

//WHILE LOOP LOOKING FOR STUFF TO DO
	while(1){
	numconnected= enet_host_service(server, &event, 1000);
	printf("hello %d", numconnected);
    /* Wait up to 1 second for an event. */
    if (numconnected > 0)
    {
		
        switch (event.type)
        {
        case ENET_EVENT_TYPE_CONNECT:
			printf("connected\n");
            printf ("A new client connected from %x:%u.\n", 
                    event.peer -> address.host,
                    event.peer -> address.port);

            /* Store any relevant client information here. */
            event.peer -> data = "Client information";

            break;

        case ENET_EVENT_TYPE_RECEIVE:
			printf("packed recieved\n");
            printf ("A packet of length %u containing %s was received from
%s on channel %u.\n",
                    event.packet -> dataLength,
                    event.packet -> data,
                    event.peer -> data,
                    event.channelID);

            /* Clean up the packet now that we're done using it. */
            enet_packet_destroy (event.packet);
            
            break;
           
        case ENET_EVENT_TYPE_DISCONNECT:
			printf("disconnected\n");
            printf ("%s disconected.\n", event.peer -> data);
			/* Reset the peer's client information. */

            event.peer -> data = NULL;
			break;

            
        }
    }

	}
	

//////////////////////////end while//////////////////////////






More information about the ENet-discuss mailing list