]> git.deb.at Git - rhonda/impostor.hazel.git/commitdiff
Fixed bug on connection failure
authorJamJar00 <jamster.30@btinternet.com>
Sat, 22 Oct 2016 00:02:39 +0000 (01:02 +0100)
committerJamJar00 <jamster.30@btinternet.com>
Sat, 22 Oct 2016 00:02:39 +0000 (01:02 +0100)
Hazel/Tcp/TcpConnection.cs
Hazel/Tcp/TcpConnectionListener.cs

index e4f8f97b3c54b71221733eaff0d6446da890132c..6ce67f3c9f3f3c496962e6abe30c3022cc628410 100644 (file)
@@ -175,7 +175,7 @@ namespace Hazel.Tcp
             }
             catch (SocketException e)
             {
-                HandleDisconnect(new HazelException("A Socket exception occured while initiating a body receive operation.", e));
+                HandleDisconnect(new HazelException("A Socket exception occured while initiating a header receive operation.", e));
             }
 
             Statistics.LogReceive(bytes.Length, bytes.Length + 4);
@@ -184,10 +184,25 @@ namespace Hazel.Tcp
             InvokeDataReceived(bytes, SendOption.FragmentedReliable);
         }
 
+        /// <summary>
+        ///     Starts this connection receiving data.
+        /// </summary>
+        internal void StartReceiving()
+        {
+            try
+            {
+                StartWaitingForHeader();
+            }
+            catch (SocketException e)
+            {
+                HandleDisconnect(new HazelException("A Socket exception occured while initiating the first receive operation.", e));
+            }
+        }
+
         /// <summary>
         ///     Starts this connections waiting for the header.
         /// </summary>
-        internal void StartWaitingForHeader()
+        void StartWaitingForHeader()
         {
             StartWaitingForBytes(4, HeaderReadCallback);
         }
index 9e174b99c8168c73320b72cf95259d923c77b6b1..2419b1be25e2e5ed501d45c7ae18b8f851da0325 100644 (file)
@@ -101,15 +101,7 @@ namespace Hazel.Tcp
                 //Invoke
                 InvokeNewConnection(tcpConnection);
 
-                try
-                {
-                    tcpConnection.StartWaitingForHeader();
-                }
-                catch (SocketException)
-                {
-                    //Receive operation couldn't be started, there's nothing we can do to save it
-                    return;
-                }
+                tcpConnection.StartReceiving();
             }
         }