Sign in to follow this  

*Solved*Enet polling

This topic is 4052 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites

This topic is 4052 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this