From dd3ebf6b34063800a8890a3a128a3076ce5adef5 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Sun, 17 Jan 2021 20:04:32 -0600 Subject: [PATCH] increase buffer size for rcon connection --- Application/RCon/ConnectionState.cs | 2 +- Application/RCon/RConConnection.cs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Application/RCon/ConnectionState.cs b/Application/RCon/ConnectionState.cs index 91307671d..b5401938e 100644 --- a/Application/RCon/ConnectionState.cs +++ b/Application/RCon/ConnectionState.cs @@ -18,7 +18,7 @@ namespace IW4MAdmin.Application.RCon } public int ConnectionAttempts { get; set; } - const int BufferSize = 8192; + private const int BufferSize = 16384; public readonly byte[] ReceiveBuffer = new byte[BufferSize]; public readonly SemaphoreSlim OnComplete = new SemaphoreSlim(1, 1); public readonly ManualResetEventSlim OnSentData = new ManualResetEventSlim(false); diff --git a/Application/RCon/RConConnection.cs b/Application/RCon/RConConnection.cs index 7ce5dc6a2..6995373db 100644 --- a/Application/RCon/RConConnection.cs +++ b/Application/RCon/RConConnection.cs @@ -430,6 +430,13 @@ namespace IW4MAdmin.Application.RCon while (sock.Available > 0) { _log.LogDebug("{available} more bytes to be read", sock.Available); + + var bufferSpaceAvailable = sock.Available + totalBytesTransferred - state.ReceiveBuffer.Length; + if (bufferSpaceAvailable >= 0 ) + { + _log.LogWarning("Not enough buffer space to store incoming data {bytesNeeded} additional bytes required", bufferSpaceAvailable); + } + state.ReceiveEventArgs.SetBuffer(state.ReceiveBuffer, totalBytesTransferred, sock.Available); if (sock.ReceiveAsync(state.ReceiveEventArgs))