views:

1337

answers:

3

I want to write a C# application where it connects to a telnet server and communicates to the server. I was wondering how a telnet server sends information to the client. I have looked (skimmed) over the Telnet RFC and looked at the incoming packets coming in from the server and still a bit confused. Can somebody give me an example how the server moves the cursor around in the telnet client and how it can change colors of characters? (An example would be most appreciated)

Update I

Here's some additional VT100 resources:

  1. ANSI/VT100 Terminal Control
  2. vt100_codes_news.txt

Update II

With much research and time, here what I found out: Telnet Programming with C#

+2  A: 

A simple Google search reveals many open source Telnet (and other network protocol) clients written in C#. You could just download the source code to one and see how they implement connection negotiation and commands.

shadit
+2  A: 

With respect to handling the cursor and text colours, etc., now you are talking about terminal emulation. For that you will need a library. This looks like a good place to start.

alxp
+7  A: 

Moving the cursor and changing the color isn't done by the telnet protocol.

Your telnet client is emulating a terminal, most probably a VT-100 variant. To move the cursor and change the color, the server sends escape sequences especific to the type of terminal being emulated (which one is sent in the telnet protocol negotiation).

If you don't want these escape sequences, telling the server on the telnet protocol negotiation you are a "dumb" terminal should be enough. If you want them (or if the server assumes everyone has a VT-100 and always sends them) you will have to implement a VT-100 terminal emulator (or at least enough of it to discard what you don't want).

CesarB
Damn....beat me to it. Good answer though, couldn't have put it better. +1
Kev
I'd also say make sure to evaluate all the RFCs - there's more than just the first one for how telnet actually works with modern computing.
Robert P