如何通过c代码增加net.core.rmem_max值 [英] How to increase net.core.rmem_max value by c code

查看:45
本文介绍了如何通过c代码增加net.core.rmem_max值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用

getsockopt(udp_fd, SOL_SOCKET, SO_RCVBUF, &rcvBufferSize, &sockOptSize)

但我不能增加它超过 rmem_max 值.

but I am not able to increase it more than rmem_max value .

如何使用 语言增加它.

How can I increase it using c language.

我不想通过命令增加它:

I don't want to increase it by command :

$ sysctl -w net.core.rmem_max=value

推荐答案

As 男人

SO_RCVBUF

以字节为单位设置或获取最大套接字接收缓冲区.这内核将此值加倍(以允许簿记空间开销),当它使用setsockopt(2) 设置时,这增加了一倍值由getsockopt(2) 返回.设置了默认值通过/proc/sys/net/core/rmem_default 文件,以及最大允许值由 /proc/sys/net/core/rmem_max 文件设置.此选项的最小(加倍)值为 256.

Sets or gets the maximum socket receive 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/rmem_default file, and the maximum allowed value is set by the /proc/sys/net/core/rmem_max file. The minimum (doubled) value for this option is 256.

强调我的

所以有了该文件的权限,您就可以直接修改它.

So with permissions on that file you can directly modify it.

这篇关于如何通过c代码增加net.core.rmem_max值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆