SFTPClient one connection - many channels

Aug 13, 2012 at 11:07 PM

Hello,

sorry for My English, I use SSH.NET (wonderful library), I try create one SFTP connection with many channels. From what I see SftpClient runs on a single channel, do I have right?

My many channels implementation:

...

/// <summary>
/// Contenner for SftpSession instances
/// </summary>
private Dictionary<uint, SftpSession> _sftpSessions = new Dictionary<uint, SftpSession>();

/// <summary>
 /// Get not used SftpSession instance that used to communicate to the SFTP server
/// </summary>
private SftpSession _sftpSession 
{
	get { return GetChanel(); } 
}

...

/// <summary>
/// Called when client is connected to the server.
/// </summary>
protected override void OnConnected()
{
	base.OnConnected();

	this._sftpSessions.Add(0, new SftpSession(this.Session, this.OperationTimeout));
	this._sftpSessions[0].Connect();

	this.ProtocolVersion = this._sftpSessions[0].ProtocolVersion;
}

private SftpSession GetChanel()
{
	uint acc = 0;

	// Create new SftpSession instance
	if (!_sftpSessions.ContainsKey(acc))
	{
		this._sftpSessions.Add(this.Session.NextChannelNumber, new SftpSession(this.Session, this.OperationTimeout));
		this._sftpSessions[acc].Connect();
	}

	return this._sftpSessions[acc];
}

But I don't know how I check whether the channel (SftpSession) is busy?