Subject: Re: Socket buffers allocations
To: None <email@example.com>
From: Christian Biere <firstname.lastname@example.org>
Date: 01/12/2007 11:23:10
Bharat Joshi wrote:
> 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.
Why before? Well, see FIONSPACE in ioctl(2).
> 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?
See kqueue(2) and EVFILT_WRITE:
EVFILT_WRITE Takes a descriptor as the identifier, and returns whenever
it is possible to write to the descriptor. For sockets,
pipes, fifos, and ttys, data will contain the amount of
space remaining in the write buffer.