Reputation: 627
I'm using Linux 2.6.38 (fc14). What is the ioctl flag to get the amount of free space on a socket file descriptor (say, a TCP socket)? I found NetBSD has FIONREAD, FIONWRITE and FIONSPACE for such related purposes. But, I could only use FIONREAD in Linux.
Upvotes: 2
Views: 3255
Reputation: 81
For information, about what @HKK says, found in man socket(7):
SO_SNDBUF
Sets or gets the maximum socket send buffer in bytes. The kernel doubles this value (to allow space for bookkeeping overhead) when it is set using setsockopt(2), and this doubled value is returned by getsockopt(2). The default value is set by the /proc/sys/net/core/wmem_default file and the maximum allowed value is set by the /proc/sys/net/core/wmem_max file. The minimum (doubled) value for this option is 2048.
Upvotes: 0
Reputation: 239011
SIOCOUTQ
is the Linux equivalent of FIONWRITE
. I don't believe there is a direct FIONSPACE
equivalent: instead, you can subtract the value returned by SIOCOUTQ
from the socket send buffer size, which can be obtained with getsockopt(s, SOL_SOCKET, SO_SNDBUF, ...)
.
Upvotes: 8