SCTP RCVBUF不是在Linux中正确设置(SCTP RCVBUF is not set pr

2019-09-20 20:45发布

I am trying to set RCVBUF to 1MB//1048576 , But after setting the value when I am trying to read it through getsockopt it always gives the value as 2MB//2097152 could anyone let me know what is the problem with the below code?

    unsigned int rcvBuf = getRcvBufValue();
    if (setsockopt (channelfd, SOL_SOCKET, SO_RCVBUF, &rcvBuf,sizeof (rcvBuf)) == -1) 
  {
         cout<<"RCV BUF IS NOT SET";
  }
      int rcvbuf = -1;
      socklen_t Rsize = sizeof(rcvbuf);
      getsockopt (channelfd, SOL_SOCKET, SO_RCVBUF,&rcvbuf,&Rsize);
      cout<<rcvbuf;

Answer 1:

这里是在说man 7 socket有关SO_RCVBUF选项:

SO_RCVBUF

设置或获取最大的套接字接收缓冲区以字节为单位。 内核加倍此值(以允许簿记开销空间),当它被使用setsockopt的(2)中设置,并且该倍值是通过的getsockopt(2)返回。 默认值是通过在/ proc / SYS /网/核心/ rmem_default文件中设置,而最大允许值是通过在/ proc / SYS /网/核心/ rmem_max文件中设置。 此选项的最小值(加倍)值为256。



文章来源: SCTP RCVBUF is not set properly in Linux
标签: linux sctp