Monday, January 26, 2009

Telnet Programming with C#

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

yazkhabiri.com/page/telnet

9 comments:

  1. You have saved my life! Excellent post!

    ReplyDelete
  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.

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

    ReplyDelete
  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.

    http://www.codeproject.com/KB/IP/MinimalisticTelnet.aspx

    ReplyDelete
  5. @Richard
    Hi Richard, the TelnetController uses TelnetHelper to run the different commands. I primarily wrote it for the Nethack server at nethack.alt.org, 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!

    ReplyDelete
  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

    http://www.xpresslearn.com/networking/code/csharp-telnet-client

    ReplyDelete
  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?

    Lam8888

    ReplyDelete
  8. Hi Lam,

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

    http://code.google.com/p/naogui/source/browse/trunk/Nethack+Online+GUI/TerminalCell.cs

    http://code.google.com/p/naogui/source/browse/trunk/Nethack+Online+GUI/NetHackController.cs

    For the rest of the files, see:

    http://code.google.com/p/naogui/source/browse/trunk/Nethack+Online+GUI/

    Hope it helps!

    ReplyDelete
  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.

    ---
    Daravuth

    ReplyDelete