This project is read-only.

Programmer's Guide

The library assembly is "TelnetLib.dll" with the class-library documentation in TelnetLib.chm. The main classes are TelnetStream and Expector both in namespace TelnetExpect. The TelnetConsole sample code shows usage of both along with the ANSI support etc, the WinForms sample in code in the CodePlex repository shows another use of the telnet- and terminal-related classes.

The Samples

The TelnetConsole and Winform1 projects show sample code for using the library.

TelnetConsole run with "-expect" shows an Expector script checking that the "Windows Time" service is running on the target machine. If the service is running the code exits cleanly, if the service is not running or an other error occurs then an exception results.

With a hostname passed on the command-line the console-based Telnet Terminal is run. In debug mode when run outside the debugger it dump tracing to stderr so run as e.g. TelnetConsole.exe unix1 2>err.txt

This console works well, with most special keystrokes being handled and sent as the necessary ANSI/vt-100 command, Shift+Tab does not seem to be supported by the XP Telnet Server unfortunately. There is a slight issue with scrolling as mentioned above, that is when we write to the bottom-right position the console scrolls we need to prevent that.

The code for running the terminal is in the Program.cs file. We use one thread to handle the keyboard and another to handle the screen (aka printer). (More encapsulation of these methods will be considered later).


This sample isn't as complete as the console version. It works ok when in 'stream' mode -- where the output is just a series of characters, but support for terminal mode where SetCursorPostion and EraseInLine etc commands are sent. The control was based on a TextBox for simplicit of the first scenario, but more work is needed to support the second scenario.

Last edited Oct 3, 2009 at 10:32 PM by alanjmcf, version 6


No comments yet.