Re: Socket read tuning on Mac OS X
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com On Apr 2, 2010, at 10:43 AM, Mo McRoberts wrote:
On Fri, Apr 2, 2010 at 15:18, Jakub Bednar <jakub.bednar@avg.com> wrote:
"Give me about xxx kB of data per read, but if
that amount is not available in a specified time, give me what you have."?
ioctl(fd, FIONREAD, &nbytes) in combination with a short sleep, perhaps? i.e., if nbytes is below the threshold, sleep for a short period and test again, if it's increased but still below the threshold, continue sleeping; if it's unchanged or above the threshold, read what's there
Jakube, You should look at kqueue.
From man kqueue:
Other socket descriptors return when there is data to be read, subject to the SO_RCVLOWAT value of the socket buffer. This may be overridden with a per- filter low water mark at the time the filter is added by setting the NOTE_LOWAT flag in fflags, and specifying the new low water mark in data. On return, data contains the number of bytes of proto- col data available to read. You can easily implement poll using kqueue if you like. Cheers, M _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com
participants (1)
-
A.M.