Subject: Re: How to find socket buffer size
To: Rob Newberry <robthedude@mac.com>
From: Prasanta Sadhukhan <Prasanta.Sadhukhan@Sun.COM>
List: netbsd-help
Date: 12/05/2006 11:50:18
Rob Newberry wrote:
>>> I think it's:
>>> sysctl kern.sbmax
>>
>> Thanks.. I knew that but the question is how to obtain the value
>> programatically?
>
>
> sysctl(3)
>
>
Thanks....I tried to limit the sock buffer to the maximum sockbuf as
specified by the kern.sbmax variable like this
int *bufsize = (int *)arg;
int mib[2], sockbufmax;
size_t len;
mib[0] = CTL_KERN;
mib[1] = KERN_SBMAX;
len = sizeof(sockbufmax);
sysctl(mib, 2, &sockbufmax, &len, NULL, 0);
if (*bufsize > sockbufmax)
*bufsize = sockbufmax;
fprintf(stdout, "buffersize %d\n", *bufsize);
fflush(stdout);
}
return setsockopt(fd, SOL_SOCKET, SO_RCVBUF, arg, len);
although kern.sbmax shows 262144 i.e., 256KB, but while setting
setsockopt for sockbufsize of 2147483646 which will get limited to
262144 I am getting -1. Only if I limit it within 227KB, then it passes
Any clue?!
Regards
Prasanta