Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Capping of sockets
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Capping of sockets



On Jun 9, 2006, at 15:30, David Aames wrote:

Thanks for your insightful reply. I think I will manage to implement rate limitting for uploading. I've also just found an article (http://doc.trolltech.com/qq/qq17-ratecontrol.html ) which implements up/down rate limitting. The interesting part is where they set a maximum buffer of the socket - if this is reached the socket will stop receiving data. Is this even possible with BSD sockets? Or I would have to resort to kernel extensions?

Use the SO_RCVBUF socket option to set the size of the receive buffer in the kernel. That's what the Trolltech code is doing underneath the layer they published in that article. Depending on the nature of your application protocol, you may also need to set the receive low water mark with SO_RCVLOWAT.


Be aware that these options do not actually force the sender to slow down-- they only control the size of the window your end advertises and when your application will be signaled to read more octets. In practice, though, it means that if the sender is respecting the TCP window, then you can use these options as a crude hammer with which to limit its rate over relatively long time intervals.

All this stuff is covered in detail in _Unix Network Programming_ <http://www.kohala.com/start/unpv12e.html>. The setsockopt(2) man page has the nut.


-- james woodyatt <email@hidden> member of technical staff apple computer, inc.

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: Capping of sockets (From: Scott Ribe <email@hidden>)
 >Re: Capping of sockets (From: David Aames <email@hidden>)
 >Re: Capping of sockets (From: james woodyatt <email@hidden>)
 >Re: Capping of sockets (From: "David Aames" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.