--- lib/network/NetworkConnection.cpp.orig	2025-12-30 11:31:58 UTC
+++ lib/network/NetworkConnection.cpp
@@ -7,6 +7,10 @@
  * Full text of license available in license.txt file, in main folder
  *
  */
+#ifdef __FreeBSD__
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#endif
 #include "StdInc.h"
 #include "NetworkConnection.h"
 
@@ -19,8 +23,15 @@ NetworkConnection::NetworkConnection(INetworkConnectio
 {
 	socket->set_option(boost::asio::ip::tcp::no_delay(true));
 
+#ifdef __FreeBSD__
+	unsigned long sb_max;
+	size_t len = sizeof(sb_max);
+	(void)sysctlbyname("kern.ipc.maxsockbuf", &sb_max, &len, NULL, 0);
+	int bufferSize = sb_max * MCLBYTES / (MSIZE + MCLBYTES);
+#else
 	// iOS throws exception on attempt to set buffer size
 	constexpr auto bufferSize = 4 * 1024 * 1024;
+#endif
 
 	try
 	{
