mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-20 05:28:01 +00:00
Make UDP send and receive buffers as big as possible to reduce packet loss.
This commit is contained in:
parent
49247180dc
commit
f764cf8d31
@ -242,6 +242,20 @@ SocketManager::SocketManager(
|
||||
#endif
|
||||
|
||||
{
|
||||
int bs = 1048576;
|
||||
while (bs >= 65536) {
|
||||
int tmpbs = bs;
|
||||
if (setsockopt(s,SOL_SOCKET,SO_RCVBUF,&tmpbs,sizeof(tmpbs)) == 0)
|
||||
break;
|
||||
bs -= 16384;
|
||||
}
|
||||
bs = 1048576;
|
||||
while (bs >= 65536) {
|
||||
int tmpbs = bs;
|
||||
if (setsockopt(s,SOL_SOCKET,SO_SNDBUF,&tmpbs,sizeof(tmpbs)) == 0)
|
||||
break;
|
||||
bs -= 16384;
|
||||
}
|
||||
#ifdef __WINDOWS__
|
||||
BOOL f;
|
||||
f = TRUE; setsockopt(s,IPPROTO_IPV6,IPV6_V6ONLY,(const char *)&f,sizeof(f));
|
||||
@ -302,6 +316,20 @@ SocketManager::SocketManager(
|
||||
#endif
|
||||
|
||||
{
|
||||
int bs = 1048576;
|
||||
while (bs >= 65536) {
|
||||
int tmpbs = bs;
|
||||
if (setsockopt(s,SOL_SOCKET,SO_RCVBUF,&tmpbs,sizeof(tmpbs)) == 0)
|
||||
break;
|
||||
bs -= 16384;
|
||||
}
|
||||
bs = 1048576;
|
||||
while (bs >= 65536) {
|
||||
int tmpbs = bs;
|
||||
if (setsockopt(s,SOL_SOCKET,SO_SNDBUF,&tmpbs,sizeof(tmpbs)) == 0)
|
||||
break;
|
||||
bs -= 16384;
|
||||
}
|
||||
#ifdef __WINDOWS__
|
||||
BOOL f;
|
||||
f = FALSE; setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(const char *)&f,sizeof(f));
|
||||
|
Loading…
Reference in New Issue
Block a user