List Info

Thread: How to find socket buffer size




How to find socket buffer size
user name
2006-12-05 04:55:53
>> I think it's:
>> sysctl kern.sbmax
> Thanks.. I knew that but the question is how to obtain
the value
> programatically?

sysctl(3)


How to find socket buffer size
user name
2006-12-05 06:20: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 %dn",
*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


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )