Re: Setting SO_SNDBUF and SO_RCVBUF

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Kulkarni, Mayuresh wrote:
> Hello,
> 
> man tcp on RHEL4 (2.6.9-68) says the following:
> 
> The maximum sizes for socket buffers declared via the SO_SNDBUF and
> SO_RCVBUF  mechanisms are limited by the global net.core.rmem_max and
> net.core.wmem_max sysctls.  Note that TCP actually allocates twice the
> size of the buffer requested in the setsockopt(2)  call,  and so a
> succeeding getsockopt(2) call will not return the same size of buffer as
> requested in the setsockopt(2) call.  TCP uses this for administrative
> purposes  and  internal  kernel structures,  and  the sysctl variables
> reflect the larger sizes compared to the actual TCP       windows.
> -->
> On individual connections, the socket buffer size must be set prior to
> the listen() or connect() calls in order to have it take effect. See
> socket(7) for more information.
> <--
> 
> Is the last bit above true - i.e. does the setsockopt have to be done
> before the connect()/listen() calls? (I seem to be able to do it at
> anytime but am not sure if TCP actually uses the new value as per the
> above comment)
> 
> Thanks,
> Mayuresh.
> 
> --------------------------------------------------------------------------
> NOTICE: If received in error, please destroy and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error. Morgan Stanley may monitor and store emails to the extent permitted by applicable law.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-net" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 

When you call socket(), it returns a descriptor (sockd), that sockd
is used to build the socket option with the call to setsockopt() -
you cannot use setsockopt() without an open sockd. Then at some
point you use the same sockd for bind(), then listen() and then accept()
to build a server connection socket.

Now, if you want to use, SO_SNDBUF and SO_RCVBUF, those have to be treated
with some timing considerations, because they are inherited by a connected TCP
socket. So, for a server socket, the socket option must be set before calling
listen(), as you have surmised.

Thanks,

LDB

--
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux