udp改變緩衝區大小
阿新 • • 發佈:2019-02-20
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傳送佇列大小