After the data is received, it should be processed immediately. This is a simple idea. However, due to limited network bandwidth, You need to limit the speed at which UDP receives data. The following code analyzes the implementation of this requirement:
#001 S32 LLPacketRing: receivePacket (S32 socket, char * datap)
#002 {
#003 S32 packet_size = 0;
#004
Next, determine whether to use the traffic limit for receiving.
#005 // If using the throttle, simulate a limited size input buffer.
#006 if (mUseInThrottle)
#007 {
#008 BOOL done = FALSE;
#009
#010 // push any current net packet (if any) onto delay ring
Next, we start to receive data cyclically and determine whether to reach the maximum traffic.
#011 while (! Done)
#012 {
#013 LLPacketBuffer * packetp;
#014 packetp = new LLPacketBuffer (socket );
#015
The LLPacketBuffer object is created above to receive data.
#016 if (packetp-> getSize ())
#017 {
#018 mActualBitsIn + = packetp-> getSize () * 8;
#019
#020 // Fake packet loss
#021 & n