Skip to main content
GameDev.net gamedev.net
🔒 Locked

*Solved*Enet polling

Started by Solance Nov 8, 2006 at 11:07 PM 0 replies 1.4k views
Original Post
Solance
Solance
When my server tries to poll enet it only gets that a client has connected when a packet is sent, here is my handeling code

while(running = true)
	{
	//printf("Waiting for event...\n");
    while (enet_host_service (server, & event, 1000) > 0)
    {
		printf("Received event...(type:%i, channel:%i, host:%i, port:%i)\n",
			event.type,
			event.channelID,
			event.peer->address.host,
			event.peer->address.port);

		switch (event.type)
        {
        case ENET_EVENT_TYPE_CONNECT:
            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 ("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 ("%s disconected.\n", event.peer -> data);

            // Reset the peer's client information.

            event.peer -> data = NULL;
        }
	}
	}
the client will detect that it is connected fine but the server never detects connection until a packet is sent and in that case it never handels the packet. ok problem corrected just need to poll in the clients main loop also

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.