Explorar el Código

Fixed IOexeception on exit

jancoow hace 10 años
padre
commit
e08a34fcd9
Se han modificado 1 ficheros con 8 adiciones y 2 borrados
  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('|');