Re: Socket read tuning on Mac OS X
Re: Socket read tuning on Mac OS X
- Subject: Re: Socket read tuning on Mac OS X
- From: "A.M." <email@hidden>
- Date: Fri, 2 Apr 2010 18:34:25 -0400
On Apr 2, 2010, at 10:43 AM, Mo McRoberts wrote:
> On Fri, Apr 2, 2010 at 15:18, Jakub Bednar <email@hidden> 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 (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden