windows:

包含的头文件#include <WinSock.h>

int nRecvBuf=64*1024;//设置为64K
setsockopt(listenSocket,SOL_SOCKET, SO_RCVBUF,(const char*)&nRecvBuf,sizeof(int));


linux:

#include <net/if.h>
#include <sys/ioctl.h>

struct ifreq ifr;
memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, "eth0", sizeof(ifr.ifr_name));
ifr.ifr_qlen = 10000;
if (-1 == ioctl(sockfd, SIOCSIFTXQLEN, &ifr))
      printf("failed to set dev eth0 queue length");
if (-1 == ioctl(sockfd, SIOCGIFTXQLEN, &ifr))
      printf("failed to get dev eth0 queue length");

改变udp发送队列大小

Logo

更多推荐