Querying maximum socket send buffer size in C?

后端 未结 2 1827
被撕碎了的回忆
被撕碎了的回忆 2021-01-24 04:53

I know I can cat /proc/sys/net/core/wmem_max to get the maximum size for SO_SNDBUF on a socket, but is there an easy way to query that value in C without going through the klud

2条回答
  •  春和景丽
    2021-01-24 05:11

    Couldn't you invoke the sysctl command on the shell (use system() or popen/pclose()) to get this information...at least avoids opening a file but may be equivalent in overall ugliness:

    system("sysctl -n net.ipv4.tcp_wmem");
    

提交回复
热议问题