Source code analysis for Second Life () Traffic Control for data reception

Source: Internet
Author: User


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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.