Parcourir la source

Fixed IOexeception on exit

jancoow il y a 10 ans
Parent
commit
e08a34fcd9
1 fichiers modifiés avec 8 ajouts et 2 suppressions
  1. 8 2
      Proftaak Remote Healthcare/FietsClientV2/TCPConnection.cs

+ 8 - 2
Proftaak Remote Healthcare/FietsClientV2/TCPConnection.cs

@@ -125,10 +125,16 @@ namespace FietsClient
 
         public void receive()
         {
-            while (true)
+             while (client.Connected)
             {
                 byte[] bytesFrom = new byte[(int)client.ReceiveBufferSize];
-                sslStream.Read(bytesFrom, 0, client.ReceiveBufferSize);
+                try {
+                    sslStream.Read(bytesFrom, 0, client.ReceiveBufferSize);
+                }
+                catch (Exception)
+                {
+                    break;
+                }
                 string response = Encoding.ASCII.GetString(bytesFrom);
                 string[] response_parts = response.Split('|');