[ENet-discuss] how to know when it's safe to call enet_peer_send()?

Martin Sherburn spacedude at konggame.co.uk
Mon Mar 17 08:09:18 PDT 2008


Hi,

Is there any reason you want to use UDP instead of TCP? It seems to me 
TCP is more suitable for streaming audio and video.

Martin.

eye at dihalt.com wrote:
> Hello.
>
> I'm new to enet and in the process of testing it right now.
> I'm interested is it possible to send huge amounts of data
> (audio, video etc) using enet. For now i have a few
> questions and will be happy is someone experienced with
> ENET will write me a few words of wisdom.
>
> 1. Let's assume that we have a fast network (100 megabit+)
> and a fast computer (3Ghz+). How to call enet_peer_send()
> so it will not eat all memory? Following example of
> "unlimited speed test" just eats up all memory becouse data
> is supplied to enet faster than enet can send it over
> network:
>
> for(; ::enet_host_service(poHost, &oEvent, 0) >= 0);)
> { // timeout '0' is used to achiev speed > 1k packets / sec
>   ENetPacket *poPacket = ::enet_packet_create(pbData, 1024,
>     ENET_PACKET_FLAG_RELIABLE);
>   _ASSERT(poPacket);
>   _VERIFY(0 == ::enet_peer_send(poPeer, 0, poPacket));
> }
>
> So i need to somehow make pauses between enet_peer_send()
> calls to give enet
> a chance to send previously queued data over network. Ok,
> following code will do a deal:
>
> for(; ::enet_host_service(poHost, &oEvent, 0) >= 0);)
> {
>   // do some magic: if > 64k of data is sent but is not
> ACK'ed yet - don't
>   // send new data to prevent overflow
>   if(poPeer->reliableDataInTransit > 1024*64) continue;
>
>   ENetPacket *poPacket = ::enet_packet_create(pbData, 1024,
>     ENET_PACKET_FLAG_RELIABLE);
>   _ASSERT(poPacket);
>   _VERIFY(0 == ::enet_peer_send(poPeer, 0, poPacket));
> }
>
> But if this method is correct, it leads to a second
> question:
>
> 2. What is the best method to determine if it's ok to make
> a enet_peer_send() call or not? For example, previous
> example uses hard-coded limit equal to 64kb of unacked data
> in transit. But such limit will result in unacked packets
> (and disconnection) on slow GPRS connection where speed is
> 4-10 kb/sec and 1000ms is a common png value. Vise versa,
> on 100 megabit network this 64k limit will slow down a
> process since network can handle much more data in transit.
>
> So, i'm confused a bit about how to send huge amounts of
> data with good speed on good connections AND no disconnects
> on bad connections. Any ideas? My current code analyses
> network speed and maintains ~ 1 seconds of data to be in
> transit. But this slows down transfer on fast connection,
> and on artifical 14kbit simulated network huge enough
> packets (like 16kb per packet) still gives disconnects :(.
> _______________________________________________
> ENet-discuss mailing list
> ENet-discuss at cubik.org
> http://lists.cubik.org/mailman/listinfo/enet-discuss
>   


This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.



More information about the ENet-discuss mailing list