Added TrySocketRead method that returns 0 (zeo) when connection is closed.
Remove SocketRead(int length) overload.
Added IsConnected extension method to Socket.
Modify MessageListener() to use this extension method as condition for the message loop.
Do not bother checking readSockets as the connected check of the socket allows us to combine both the connection closed and socket disposed conditions.
Fixes issue #84.
Eliminate public Close() method and its use within SSH.NET.
Remove wait bool from protected Close(bool) method.
The protected Close() method will now always wait for a SSH_MSG_CHANNEL_CLOSE if the client initiated closing the channel.
Introduce dispose lock to resolve race condition in IsConnected/IsSocketConnected.
Rename _socketLock to _socketWriteLock
Eliminate extra allocations in ReceiveMessage, and combine two socket reads.
Use separate lock to eliminate race condition in IsSocketConnected between Poll and checking the Available property.
Modify SocketRead(int length, byte[] buffer) to also take offset.
Modify MessageListener to use Select instead of blocking Receive.
Fixes issue #80.
Reduces - but does not eliminate - likelyhood of race condition when remote server and client attempt to disconnect at the same time.
Currently this leads to a NRE or ObjectDisposedException in Session.IsSocketConnected(ref bool isConnected) when one thread is attempting to check whether the socket is still connected, and the other thread is disposing the socket.
This commit just reduces the likelyhood as the message loop thread that handes the SSH_MSG_DISCONNECT sent by the server will no longer attempt to send a SSH_MSG_DISCONNECT to the server, and as such will not check whether the socket is still connected.
- Remove ZeroReaderIndex from SshData; offset should instead be specified when instance is created/loaded.
- LoadBytes is now private, and is always invoked when a message is loaded.
- Eliminate ResetReader().
SshDataStream.cs:
- Added overload taking buffer, offset and count.
KeyExchange*Message.cs:
- Remove ResetReader() calls.
Message.cs:
- Remove ZeroReaderIndex override.
SftpMessage.cs:
- Pass offset and count to Load overload to allow skipping byte representing the message type.
- Remove ZeroReaderIndex override.
SftpSession.cs:
- Avoid buffering when packet contains full SFTP response message.
Session.cs:
- Pass offset and count to Load overload to allow skipping offset bytes.
General:
- Temporarily add (too) verbose tracing.