sshnet / SSH.NET

SSH.NET is a Secure Shell (SSH) library for .NET, optimized for parallelism.
http://sshnet.github.io/SSH.NET/
MIT License
3.88k stars 917 forks source link

Add `Closed` event to `ShellStream`. #1332

Closed scott-xu closed 4 months ago

scott-xu commented 4 months ago

Lib consumer could hook to this event to detect if channel is closed by server in time. Closes https://github.com/sshnet/SSH.NET/issues/44

jscarle commented 4 months ago

Can you please link https://github.com/sshnet/SSH.NET/issues/44 in your description to close it with this PR?

scott-xu commented 4 months ago

In our case, for some reason, the server may send channel close message to the client. As the client, we want to know this event in time and do some follow up work. I checked the existing unit tests but no related cases found.

scott-xu commented 4 months ago

Can you please link #44 in your description to close it with this PR?

I should search first. Anyway I'm not alone. Thanks!

Rob-Hague commented 4 months ago

What's the use case here?

Now that Read blocks until the channel is closed, can you just wait until Read returns 0?

scott-xu commented 4 months ago

What's the use case here?

Now that Read blocks until the channel is closed, can you just wait until Read returns 0?

We don't call Read. We use Write method and DataRecieved event. You can check my previous comment for use case.

WojciechNagorski commented 4 months ago

I think we can merge this PR. Fits the current SSH.NET architecture.