mirror of
https://github.com/sshnet/SSH.NET.git
synced 2026-10-18 22:44:56 +08:00
Added a comment regarding exception thrown when local socket is dead, as it shows up as first-chance exception in the output window.
This commit is contained in:
@@ -80,6 +80,13 @@ namespace Renci.SshNet
|
||||
response = encoding.GetString(buffer.Take(buffer.Count - 1).ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Function to read <paramref name="length"/> amount of data before returning, or throwing an exception.
|
||||
/// </summary>
|
||||
/// <param name="length">The amount wanted.</param>
|
||||
/// <param name="buffer">The buffer to read to.</param>
|
||||
/// <exception cref="SshConnectionException">Happens when the socket is closed.</exception>
|
||||
/// <exception cref="Exception">Unhandled exception.</exception>
|
||||
partial void SocketRead(int length, ref byte[] buffer)
|
||||
{
|
||||
var offset = 0;
|
||||
@@ -97,7 +104,17 @@ namespace Renci.SshNet
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new SshConnectionException("An established connection was aborted by the software in your host machine.", DisconnectReason.ConnectionLost);
|
||||
// 2012-09-11: Kenneth_aa
|
||||
// When Disconnect or Dispose is called, this throws SshConnectionException(), which...
|
||||
// 1 - goes up to ReceiveMessage()
|
||||
// 2 - up again to MessageListener()
|
||||
// which is where there is a catch-all exception block so it can notify event listeners.
|
||||
// 3 - MessageListener then again calls RaiseError().
|
||||
// There the exception is checked for the exception thrown here (ConnectionLost), and if it matches it will not call Session.SendDisconnect().
|
||||
//
|
||||
// Adding a check for this._isDisconnecting causes ReceiveMessage() to throw SshConnectionException: "Bad packet length {0}".
|
||||
//
|
||||
throw new SshConnectionException("An established connection was aborted by the software in your host machine.", DisconnectReason.ConnectionLost);
|
||||
}
|
||||
}
|
||||
catch (SocketException exp)
|
||||
|
||||
Reference in New Issue
Block a user