Skip to contentSkip to conversation

setsockopt(..,SO_RCVBUF,..) sets wrong value

DISCUSSION Manfred Bartz 2 participants 2 messages Aug 2, 2001

lore
Share & tools
lore
#0 lore raw

When I do a setsockopt(..,SO_RCVBUF,..) and then read the value back with getsockopt(), the reported value is exactly twice of what I set.

Running the same code on Solaris and on DEC UNIX reports back the exact size I set.

Looking at the code it seems that the *2 should not be there:

Quoted 1 line

From /usr/src/linux/net/core/sock.c:

int sock_setsockopt(...

		case SO_SNDBUF:

			sk->sndbuf = max(val*2,SOCK_MIN_SNDBUF);

		case SO_RCVBUF:
			/* FIXME: is this lower bound the right one? */
			sk->rcvbuf = max(val*2,SOCK_MIN_RCVBUF);
			break;
Signature · 1 line
Manfred Bartz
#1 lore raw
Quoted 2 lines · Manfred Bartz

When I do a setsockopt(..,SO_RCVBUF,..) and then read the value back with getsockopt(), the reported value is exactly twice of what I set.

That's correct. Please search the list archives to learn why things behave this way and why they are not going to change.

I wish that this long winded, and often occuring thread not occur again.

Later,
David S. Miller
[email protected]