From 85b332ae72746ff656b14c85c1ef9fd923e58cc2 Mon Sep 17 00:00:00 2001 From: Stone_Red <56473591+Stone-Red-Code@users.noreply.github.com> Date: Thu, 14 Dec 2023 22:42:15 +0100 Subject: [PATCH] Fix `TcpClient` getting disposed of too early --- HyperbolicDownloaderApi/Networking/NetworkClient.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/HyperbolicDownloaderApi/Networking/NetworkClient.cs b/HyperbolicDownloaderApi/Networking/NetworkClient.cs index 6902a75..235f5a7 100644 --- a/HyperbolicDownloaderApi/Networking/NetworkClient.cs +++ b/HyperbolicDownloaderApi/Networking/NetworkClient.cs @@ -94,7 +94,7 @@ internal class NetworkClient(FilesManager filesManager) { ApiManager.SendNotificationMessageNewLine("Listening for connections...", NotificationMessageType.Debug); - using TcpClient client = tcpListener.AcceptTcpClient(); + TcpClient client = tcpListener.AcceptTcpClient(); ApiManager.SendNotificationMessageNewLine($"{(client.Client.RemoteEndPoint as IPEndPoint)?.Address} > Connected", NotificationMessageType.Debug); @@ -178,6 +178,8 @@ internal class NetworkClient(FilesManager filesManager) } ApiManager.SendNotificationMessageNewLine($"{(client.Client.RemoteEndPoint as IPEndPoint)?.Address} > End of request", NotificationMessageType.Debug); + + client.Close(); } private async Task Upload(TcpClient client, string hash)