Subject: Socket buffers allocations
To: None <tech-net@netbsd.org>
From: Bharat Joshi <bharat.josh@gmail.com>
List: tech-net
Date: 01/12/2007 09:46:35
Hi,

        Couple of related questions:

        I am developing an application where I need to check whether a
socket is ready for write or not. I can do that using select, poll or
kqueue and I have chosen 'kqueue' to do it.

        Before adding the socket to 'kqueue', I want to check if there
is enough space in socket buffer for a write to be successful. My
first question is that is there a IOCTL/GETSOCKOPT option using which
I can find out the space available in the send socket buffer?

        I was also looking to increase the size of the socket buffers
after opening the socket. But I wanted to confirm that Kernel does not
pre-allocate the memory for socket buffers and so I looked at the
kernel code and it seems to me that kernel does not pre-allocate these
buffers and the mbufs get allocated as and when a message is sent. Can
someone please confirm this behaviour for me?

        If the answer to the above question is that 'buffers are not
pre-allocated"  than another question is that if I increase the size
of the socket buffers, will it adversely affect any kernel
functionality?

Thanks,
Bharat