From 2f22f28a4d021bf0318f2ae391bd965710e967eb Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 29 Mar 2025 00:59:23 +0100 Subject: [PATCH] try to set the socket buffer to 208k this is what i get on nix, while windoze seems to be stuck on 64k, maybe fixed the occasional network buffer overrun that happens --- src/i_tcp.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/i_tcp.c b/src/i_tcp.c index 012244450..bdf6d09c8 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -970,7 +970,28 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&opt, &opts); CONS_Printf(M_GetText("Network system buffer: %dKb\n"), opt>>10); - if (opt < 64<<10) // 64k + if (opt < 208<<10) // 208k this is what i have on my arch system + { + opt = 208<<10; + opts = (socklen_t)sizeof(opt); + setsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&opt, opts); + getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&opt, &opts); + if (opt < 208<<10) + { + CONS_Alert(CONS_WARNING, M_GetText("Can't set buffer length to 208k, retrying with 128k\n")); + opt = 128<<10; + opts = (socklen_t)sizeof(opt); + setsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&opt, opts); + getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&opt, &opts); + + if (opt < 128<<10) + CONS_Alert(CONS_WARNING, M_GetText("Can't set buffer length to 128k, file transfer will be bad\n")); + else + CONS_Printf(M_GetText("Network system buffer set to: %dKb\n"), opt>>10); + } + } + + /*if (opt < 64<<10) // 64k { opt = 64<<10; opts = (socklen_t)sizeof(opt); @@ -980,7 +1001,7 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen CONS_Alert(CONS_WARNING, M_GetText("Can't set buffer length to 64k, file transfer will be bad\n")); else CONS_Printf(M_GetText("Network system buffer set to: %dKb\n"), opt>>10); - } + }*/ if (getsockname(s, (struct sockaddr *)&sin, &len) == -1) CONS_Alert(CONS_WARNING, M_GetText("Failed to get port number\n"));