فهرست منبع

Do not catching exceptions while clearing read buffer of socket.
Leave this up to the caller.

drieseng 9 سال پیش
والد
کامیت
77e7bc8c04
1فایلهای تغییر یافته به همراه6 افزوده شده و 11 حذف شده
  1. 6 11
      src/Renci.SshNet/Abstractions/SocketAbstraction.cs

+ 6 - 11
src/Renci.SshNet/Abstractions/SocketAbstraction.cs

@@ -81,20 +81,15 @@ namespace Renci.SshNet.Abstractions
 
         public static void ClearReadBuffer(Socket socket)
         {
-            try
-            {
-                var buffer = new byte[256];
-                int bytesReceived;
+            var timeout = TimeSpan.FromMilliseconds(10);
+            var buffer = new byte[256];
+            int bytesReceived;
 
-                do
-                {
-                    bytesReceived = ReadPartial(socket, buffer, 0, buffer.Length, TimeSpan.FromMilliseconds(10));
-                } while (bytesReceived > 0);
-            }
-            catch
+            do
             {
-                // ignore any exceptions
+                bytesReceived = ReadPartial(socket, buffer, 0, buffer.Length, timeout);
             }
+            while (bytesReceived > 0);
         }
 
         public static int ReadPartial(Socket socket, byte[] buffer, int offset, int size, TimeSpan timeout)