Monday, January 26, 2009

Telnet Programming with C#

Hi, thank you for visiting. The article is maintained on:


  1. You have saved my life! Excellent post!

  2. The code is great! It should help tremendously on a new project. thanks. Question tho, in your TelnetController code, the TCPConnection object ... is this a custom class? or am I missing a using directive that I can't find.

  3. @skuiper: TCPConnection is a small class I wrote to control the socket, its code can be found here.

  4. Your code looks great, but I'm just starting out with c# and it was a bit too complex for me to modify for my needs. Best C# Telnet Lib I've found is called Minimalistic Telnet. Very easy to understand, use and modify. It works great for the Cisco routers I need to configure.

  5. @Richard
    Hi Richard, the TelnetController uses TelnetHelper to run the different commands. I primarily wrote it for the Nethack server at, so there probably some bias in my programming ;)

    At a cursory glance through Minimalistic Telnet and my code shows that their TelnetInterface is the (rough) equivalent to my TelnetHelper and Program.cs to TelnetController. Maybe you can use this as a starting point to add additional features to the code.

    Hope it helps!

  6. Here is an article I did that compiles the source of a telnet library found on c-sharpcorner along with an example program that uses it.

    The example performs a login to a Cisco router and downloads the configuration

  7. srand,
    I have a question about your code.
    Is the "TerminalCell" a class? Also is "NetHackController" type?
    Did I miss something to down load?


  8. Hi Lam,

    Yes TerminalCell and NetHackController are both classes in the project, see:

    For the rest of the files, see:

    Hope it helps!

  9. Hi,

    Thanks for the post. It's really useful.

    Currently, i could connect to my testing cisco switch via c#.
    However, would you please help to advise how i construct the command to send to the switch, and how could i send and get back the result.

    thanks for your help.