gpt4 book ai didi

linux - 设置套接字接收缓冲区大小,被截断为 244KB

转载 作者:太空宇宙 更新时间:2023-11-04 09:32:04 25 4
gpt4 key购买 nike

我试图在 Linux 上使用 setsockopt() 来增加套接字接收缓冲区的大小。我可以成功地将它设置为低于 244KB 的任何值。任何超过 244KB 的值都会被截断为 244KB。

似乎存在某种系统限制,但我不知道它来自哪里,因为它与以下值不对应:

$ cat /proc/sys/net/ipv4/tcp_rmem 
4096 87380 4194304
$ cat /proc/sys/net/ipv4/tcp_wmem
4096 16384 4194304
$ cat /proc/sys/net/core/rmem_default
124928
$ cat /proc/sys/net/core/wmem_default
124928

默认值是预期的 87380,但我无法将其增加到 4194304。它被限制为 244KB。有趣的是,该值是 2X rmem_default,我需要更改它吗?

谢谢

最佳答案

来自 TCP 的手册页:

   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 suc-
ceeding getsockopt(2) call will not return the same size of buffer as
requested in the setsockopt(2) call

因此,您为 SO_SNDBUF/SO_RCVBUF 传递的内容在分配时会加倍。因此,您不能在 setsockopt

中传递最大值 (4194304)

关于linux - 设置套接字接收缓冲区大小,被截断为 244KB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30310464/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com