All of lore.kernel.org
 help / color / mirror / Atom feed
* getsockopt/setsockopt with SO_RCVBUF and SO_SNDBUF "non-standard" behaviour
@ 2012-07-17  9:27 Eugen Dedu
  2012-07-18 15:59 ` Eugen Dedu
  0 siblings, 1 reply; 5+ messages in thread
From: Eugen Dedu @ 2012-07-17  9:27 UTC (permalink / raw)
  To: linux-kernel

Hi all,

I looked on Internet and at the old thread 
http://lkml.indiana.edu/hypermail/linux/kernel/0108.0/0275.html, but the 
issue is still not settled as far as I see.

I need to have the highest memory available for snd/rcv buffer and I 
need to know/confirm how much it allocated for my process (how much I 
can use).

So with Linux we need to do something like:
setsockopt (..., SO_RCVBUF, 256000, ...)
getsockopt (..., SO_RCVBUF, &i, ...)
i /= 2;

where i is the size I am looking for.

Now, to make this code work for other OSes it should be changed to:
setsockopt (..., SO_RCVBUF, 256000, ...)
getsockopt (..., SO_RCVBUF, &i, ...)
#ifdef LINUX
i /= 2;
#endif

First question, is this code correct?  If not, what code gives the 
amount of memory useable for my process?

Second, it seems to me that linux is definitely "non-standard" here. 
Saying that linux uses twice as memory has nothing to do with that, 
since getsockopt should return what the application can count on, not 
what is the internal use.  It is like a hypothetical malloc (10) would 
return not 10, but 20 (including meta-information).  Is that right?

Cheers,
-- 
Eugen Dedu
http://eugen.dedu.free.fr

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-07-19 16:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-17  9:27 getsockopt/setsockopt with SO_RCVBUF and SO_SNDBUF "non-standard" behaviour Eugen Dedu
2012-07-18 15:59 ` Eugen Dedu
2012-07-18 16:11   ` Eric Dumazet
2012-07-18 17:32     ` Rick Jones
2012-07-19 16:14       ` Eugen Dedu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.