9swampy / Telnet

Published on Nuget at https://www.nuget.org/packages/Telnet

Home Page:http://www.nugetmusthaves.com/Package/Telnet

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to detect/handle remote disconnection?

hambroz opened this issue · comments

Hi there,

First let me thank you for your great effort! Now, I tried to create something really simple, similar to PuTTY Telnet client. The main difference is that PuTTY is correctly able to handle when the other party decides to disconnect (e.g. after issuing a command like "exit" or so). I found no way how to determine such a condition other than waiting a long time and then eventually failing on a write operation.

Is there any way to determine that the other party sent the FIN flag?

Thanks and cheers,

Jan

Being fair a lot of the credit should go to Tom Janssens, but thanks nonetheless :)

This isn't something the library is set up to handle atm, but no reason your client couldn't include some sort of listener or event mechanism to detect the flag and respond appropriately. I'm not sure it would be appropriate to add said listener to the library, but I'd be very happy to consider a pull request if you go down an event raising route.