Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#ActualTispe

Posted 26 June 2013 - 09:23 AM

I have a few more questions I hope you don't mind answering.

 

The function 

enet_packet_create (const void *data, size_t dataLength, enet_uint32 flags)

Creates a packet that may be sent to a peer. The tutorial states "Optionally, initial data may be specified to copy into the packet." Does that mean that this function copy the data pointed to by void *data to its own allocated space, such that I can deallocate void *data after this function call?

 

 

Do these functions

enet_host_check_events (ENetHost *host, ENetEvent *event)
enet_host_service (ENetHost *host, ENetEvent *event, enet_uint32 timeout)

perform the same thing, only the latter blocks until timeout. Meaning it will act exactly the same if timeout = 0 is passed? So I should use the first if I don't want to block? Is it more optimized?

 

 

In this code

ENetEvent event;
    while (enet_host_service (client, & event, 1000) > 0)
    {
        switch (event.type)
        {
        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); 

The packet source is known from the .peer member, does the library retain the data internally?

 

 

When connecting to a host

/* Initiate the connection, allocating the two channels 0 and 1. */
ENetPeer *peer;
peer = enet_host_connect (client, & address, 2, 0); 
if (peer == NULL)
    {
       fprintf (stderr, 
                "No available peers for initiating an ENet connection.\n");
       exit (EXIT_FAILURE);
    }
The "peer" object/pointer, cannot possibly know if a connection has been established that fast? What happens here? Does this function block until it get a response? Is it necessary to keep this return value when I can always get it back when "event.type == ENET_EVENT_TYPE_CONNECT" ? Heck, why even get the return value when I get the peer anyway from "ENET_EVENT_TYPE_RECEIVE"?
 
 
From the website:
"ENet aggregates all protocol commands, including acknowledgements and packet transfer, into larger protocol packets to ensure the proper utilization of the connection and to limit the opportunities for packet loss that might otherwise result in further delivery latency."
Will ENet merge packets up until MTU? What if the last packet to be merged exceed MTU, can it be fragmented onto the next aggregated packet? (I know this is transparent to the programmer I just want to know).
 
 
Regarding Sequencing and Channels, If I were to send two packets on the same channel they would each get each get an unique sequencing number. And if the latest packet arrives first, then the other packet would be discarded when not in reliable mode. This is good for when you constantly send your character position. But what if I were to send two different data structs, one containing position and the other containing something else, that something else which may take slighly longer time will never get to the server. So, is it wise to have one packet type per channel?
 
 
Does the library start any threads? Does it have any internal buffers that store packets, or does it only get them from the OS when the library functions are called? I don't see any "Tick()" functions....
 
 
I read somewhere to get the ping I should write my own layer to send a timestamp to my peer who will echo it back, then I compare the timestamp packet with the current time to deterime ping, is this right or does have the library have this feature under the hood?
 
 
Finally, how do I get the DataRate(Kbps, Mbps etc) and can I get them per channel?

#2Tispe

Posted 26 June 2013 - 09:18 AM

I have a few more questions I hope you don't mind answering.

 

The function 

enet_packet_create (const void *data, size_t dataLength, enet_uint32 flags)

Creates a packet that may be sent to a peer. The tutorial states "Optionally, initial data may be specified to copy into the packet." Does that mean that this function copy the data pointed to by void *data to its own allocated space, such that I can deallocate void *data after this function call?

 

 

Do these functions

enet_host_check_events (ENetHost *host, ENetEvent *event)
enet_host_service (ENetHost *host, ENetEvent *event, enet_uint32 timeout)

perform the same thing, only the latter blocks until timeout. Meaning it will act exactly the same if timeout = 0 is passed? So I should use the first if I don't want to block? Is it more optimized?

 

 

When connecting to a host

/* Initiate the connection, allocating the two channels 0 and 1. */
ENetPeer *peer;
peer = enet_host_connect (client, & address, 2, 0); 
if (peer == NULL)
    {
       fprintf (stderr, 
                "No available peers for initiating an ENet connection.\n");
       exit (EXIT_FAILURE);
    }
The "peer" object/pointer, cannot possibly know if a connection has been established that fast? What happens here? Does this function block until it get a response? Is it necessary to keep this return value when I can always get it back when "event.type == ENET_EVENT_TYPE_CONNECT" ?
 
 
From the website:
"ENet aggregates all protocol commands, including acknowledgements and packet transfer, into larger protocol packets to ensure the proper utilization of the connection and to limit the opportunities for packet loss that might otherwise result in further delivery latency."
Will ENet merge packets up until MTU? What if the last packet to be merged exceed MTU, can it be fragmented onto the next aggregated packet? (I know this is transparent to the programmer I just want to know).
 
 
Regarding Sequencing and Channels, If I were to send two packets on the same channel they would each get each get an unique sequencing number. And if the latest packet arrives first, then the other packet would be discarded when not in reliable mode. This is good for when you constantly send your character position. But what if I were to send two different data structs, one containing position and the other containing something else, that something else which may take slighly longer time will never get to the server. So, is it wise to have one packet type per channel?
 
 
Does the library start any threads? Does it have any internal buffers that store packets, or does it only get them from the OS when the library functions are called? I don't see any "Tick()" functions....
 
 
I read somewhere to get the ping I should write my own layer to send a timestamp to my peer who will echo it back, then I compare the timestamp packet with the current time to deterime ping, is this right or does have the library have this feature under the hood?
 
 
Finally, how do I get the DataRate(Kbps, Mbps etc) and can I get them per channel?

#1Tispe

Posted 26 June 2013 - 09:17 AM

I have a few more questions I hope you don't mind answering.

 

The function 

enet_packet_create (const void *data, size_t dataLength, enet_uint32 flags)

Creates a packet that may be sent to a peer. The tutorial states "Optionally, initial data may be specified to copy into the packet." Does that mean that this function copy the data pointer to by void *data to its own allocated space, such that I can deallocate void *data after this function call?

 

 

Do these functions

enet_host_check_events (ENetHost *host, ENetEvent *event)
enet_host_service (ENetHost *host, ENetEvent *event, enet_uint32 timeout)

perform the same thing, only the latter blocks until timeout. Meaning it will act exactly the same if timeout = 0 is passed? So I should use the first if I don't want to block? Is it more optimized?

 

 

When connecting to a host

/* Initiate the connection, allocating the two channels 0 and 1. */
ENetPeer *peer;
peer = enet_host_connect (client, & address, 2, 0); 
if (peer == NULL)
    {
       fprintf (stderr, 
                "No available peers for initiating an ENet connection.\n");
       exit (EXIT_FAILURE);
    }
The "peer" object/pointer, cannot possibly know if a connection has been established that fast? What happens here? Does this function block until it get a response? Is it necessary to keep this return value when I can always get it back when "event.type == ENET_EVENT_TYPE_CONNECT" ?
 
 
From the website:
"ENet aggregates all protocol commands, including acknowledgements and packet transfer, into larger protocol packets to ensure the proper utilization of the connection and to limit the opportunities for packet loss that might otherwise result in further delivery latency."
Will ENet merge packets up until MTU? What if the last packet to be merged exceed MTU, can it be fragmented onto the next aggregated packet? (I know this is transparent to the programmer I just want to know).
 
 
Regarding Sequencing and Channels, If I were to send two packets on the same channel they would each get each get an unique sequencing number. And if the latest packet arrives first, then the other packet would be discarded when not in reliable mode. This is good for when you constantly send your character position. But what if I were to send two different data structs, one containing position and the other containing something else, that something else which may take slighly longer time will never get to the server. So, is it wise to have one packet type per channel?
 
 
Does the library start any threads? Does it have any internal buffers that store packets, or does it only get them from the OS when the library functions are called? I don't see any "Tick()" functions....
 
 
I read somewhere to get the ping I should write my own layer to send a timestamp to my peer who will echo it back, then I compare the timestamp packet with the current time to deterime ping, is this right or does have the library have this feature under the hood?
 
 
Finally, how do I get the DataRate(Kbps, Mbps etc) and can I get them per channel?

PARTNERS