set/getsockopt

  1. Understanding set/getsockopt SO_SNDBUF
  2. SOCKET(7)

If you want to set send/receive buffer size of socket, you have two step as below.

  1. set rmem_max or wmem_max
  char   sTemp = {0};
  int    nNewBufferSize = 32*1024;

  sprintf(sTemp, "echo %d > /proc/sys/net/core/rmem_max");

  /*
  sprintf(sTemp, "echo %d > /proc/sys/net/core/wmem_max");
  */

2.set SO_SNDBUF or SO_RCVBUF of socket by setsockopt

int nNewBufferSize = 32*1024;

setsockopt(socket,SOL_S0CKET,SO_SNDBUF,(char *)&nNewBufferSize,sizeof(nNewBufferSize));

SO_RCVBUF: 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_SNDBUF: The default value is set by the /proc/sys/net/core/wmem_default file and the maximum allowed value is set by the /proc/sys/net/core/wmem_max file. The minimum (doubled) value for this option is 2048.

results matching ""

    No results matching ""