From 6ec09ec99536c22203eaf22c90885c8ce8f0c3e2 Mon Sep 17 00:00:00 2001 From: shinichi Date: Fri, 16 Oct 2020 10:51:45 +0200 Subject: [PATCH] error catching --- ClientApp/Utils/Client.cs | 2 +- Server/Client.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ClientApp/Utils/Client.cs b/ClientApp/Utils/Client.cs index 7a4dd03..e292e0e 100644 --- a/ClientApp/Utils/Client.cs +++ b/ClientApp/Utils/Client.cs @@ -87,7 +87,7 @@ namespace ClientApp.Utils /// the result of the async read private void OnRead(IAsyncResult ar) { - if (ar == null || (!ar.IsCompleted)) + if (ar == null || (!ar.IsCompleted) || (!this.stream.CanRead)) return; diff --git a/Server/Client.cs b/Server/Client.cs index 07cd69d..3843f52 100644 --- a/Server/Client.cs +++ b/Server/Client.cs @@ -34,7 +34,7 @@ namespace Server private void OnRead(IAsyncResult ar) { - if (ar == null || (!ar.IsCompleted)) + if (ar == null || (!ar.IsCompleted) || (!this.stream.CanRead)) return; int receivedBytes = this.stream.EndRead(ar);