Skip to content

Commit

Permalink
Reduce buffer size to 16kb
Browse files Browse the repository at this point in the history
  • Loading branch information
cristipufu committed Oct 28, 2024
1 parent eb74aad commit c813852
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Tunnelite.Client/Tunnelite.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<Description>Tool for tunneling URLs</Description>
<PackageProjectUrl>https://github.com/cristipufu/ws-tunnel-signalr</PackageProjectUrl>
<RepositoryUrl>https://github.com/cristipufu/ws-tunnel-signalr</RepositoryUrl>
<Version>1.1.6</Version>
<Version>1.1.7</Version>
<IsPackable>true</IsPackable>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/Tunnelite.Sdk/TcpTunnel/TcpTunnelClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ private async Task StreamOutgoingAsync(TcpClient localClient, TcpConnection tcpC

private async IAsyncEnumerable<ReadOnlyMemory<byte>> StreamLocalTcpAsync(TcpClient localClient, TcpConnection tcpConnection, [EnumeratorCancellation] CancellationToken cancellationToken)
{
const int chunkSize = 32 * 1024;
const int chunkSize = 16 * 1024;

byte[] buffer = ArrayPool<byte>.Shared.Rent(chunkSize);

Expand Down
5 changes: 3 additions & 2 deletions src/Tunnelite.Server/TcpTunnel/TcpTunnelHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,16 @@ public async IAsyncEnumerable<ReadOnlyMemory<byte>> StreamIncomingAsync(TcpConne
yield break;
}

const int chunkSize = 32 * 1024;
const int chunkSize = 16 * 1024;

byte[] buffer = ArrayPool<byte>.Shared.Rent(chunkSize);

int bytesRead;

try
{
var stream = tcpClient.GetStream();

int bytesRead;

while (!Context.ConnectionAborted.IsCancellationRequested &&
(bytesRead = await stream.ReadAsync(buffer, Context.ConnectionAborted)) > 0)
Expand Down
3 changes: 3 additions & 0 deletions test/Test.TcpClient/instructions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.\Test.TcpServer.exe 5000 file.mp4
.\Test.TcpClient.exe localhost 62340 "files"
.\Tunnelite.Client.exe tcp://localhost:5000 --publicUrl https://localhost:7193/ --log Debug

0 comments on commit c813852

Please sign in to comment.