Friday, February 29, 2008

How to set the Maximum Packet Size for the UDP Socket Buffer Size ?

How to set the Maximum Packet Size for the UDP Socket Buffer Size ?

-------------------------------------------------------------------------------
#define UDP_TX_BUF_SIZE 32768

#define UDP_MAX_PKT_SIZE 65536

// set udp recv buffer size to at least the largest possible udp packet

//size to avoid losing data on OSes that set this too low by default.

int optlen = sizeof(tmp);

if (!getsockopt(udp_fd, SOL_SOCKET, SO_RCVBUF, &tmp, &optlen) && ( tmp <>

{ tmp = UDP_MAX_PKT_SIZE;

setsockopt(udp_fd, SOL_SOCKET, SO_RCVBUF, &tmp, sizeof(tmp));

}

No comments: