Why changing value of SO_RCVBUF doesn't work?

后端 未结 2 491
别那么骄傲
别那么骄傲 2020-11-29 10:16

I\'m making a program which create a RAW socket in order to read all traffic. Between the call of socket() and recvfrom() (last one is in a loop to get out all packets from

2条回答
  •  天命终不由人
    2020-11-29 11:01

    The level argument to setsockopt should be SOL_SOCKET, not 0:

    int a = 65535;
    if (setsockopt(sockfd, SOL_SOCKET, SO_RCVBUF, &a, sizeof(int)) == -1) {
        fprintf(stderr, "Error setting socket opts: %s\n", strerror(errno));
    }
    

提交回复
热议问题