Telnet



Click here for larger image

Environment: VC6, NT4.0 SP3, not tested on 95 and VC5

The purpose of the TELNET Protocol is to provide a fairly general, bi-directional, eight-bit byte oriented communications facility. Its primary goal is to allow a standard method of interfacing terminal devices and terminal-oriented processes to each other. It is envisioned that the protocol may also be used for terminal-terminal communication ("linking") and process-process communication (distributed computation).GENERAL CONSIDERATIONS A TELNET connection is a Transmission Control Protocol (TCP) connection used to transmit data with interspersed TELNET control information. The TELNET Protocol is built upon three main ideas: first, the concept of a "Network Virtual Terminal"; second, the principle of negotiated options; and third, a symmetric view of terminals and processes.

When a TELNET connection is first established, each end is assumed to originate and terminate at a "Network Virtual Terminal", or NVT. An NVT is an imaginary device which provides a standard, network-wide, intermediate representation of a canonical terminal. This eliminates the need for "server" and "user" hosts to keep information about the characteristics of each other's terminals and terminal handling conventions. All hosts, both user and server, map their local device characteristics and conventions so as to appear to be dealing with an NVT over the network, and each can assume a similar mapping by the other party. The NVT is intended to strike a balance between being overly restricted (not providing hosts a rich enough vocabulary for mapping into their local character sets), and being overly inclusive (penalizing users with modest terminals).

This Project has several main classes

CSocketDx

CSocketDx Class is used to establish TCP connection. In addition to the constructor and destructor it has 3 functions:

  • CSocketDx(char *,int);
  • ~CSocketDx();
  • int Create();
  • int Connect();
  • SOCKET TelnetConnect();

CSocketRx

CSocketRx Class is used to receive data. It has only one thread.

  • CSocketRx();
  • CSocketRx(SOCKET,HANDLE&);
  • virtual ~CSocketRx();
  • static DWORD RdTh(CSocketRx *);

CSocketTx

CSocketTx Class is used to send data. It has only one thread.

  • CSocketTx(SOCKET,HANDLE&);
  • virtual ~CSocketTx();
  • static DWORD SendTh(CSocketTx*);

CProtocolRx

CProtocolRx Class is used to implement Telnet protocol.

inline void yesreply(SOCKET server, _verb verb,_option option);
inline void noreply(SOCKET server, _verb verb,_option option);
inline void askfor(SOCKET server, _verb verb,_option option);
void TelentProtcol(SOCKET server,unsigned char code);

Downloads

Download source - 42 Kb


Comments

  • telnet

    Posted by Legacy on 09/04/2003 12:00am

    Originally posted by: sambasivarao

    guys,
    
    

    i did not understand aim of this project.
    can any body help me.
    what it does.

    just in 2 sentences.is there any need of any hardware devices.


    regards
    samba

    Reply
  • code use in linux ?

    Posted by Legacy on 03/15/2003 12:00am

    Originally posted by: jiali

    Can you tell me where i could find any simple c code that could used in linux?
    I just want to use the telnet protocol to send serval commands to do some works automatically.
    thanks.

    Reply
  • difference...

    Posted by Legacy on 03/05/2003 12:00am

    Originally posted by: Thirumalai

    can u tell me the differece between ur Telnet console application and previous Telnet Protocol which is normally using in Linux/unix

    Reply
  • poor quality...

    Posted by Legacy on 01/09/2003 12:00am

    Originally posted by: Ole Dole Doff

    While looking the web for a telnet implementation I came across this code. I'm sad to say but the quality of this piece of code is very poor. I could not find many others and the few ones I found was either part of a more complex product and hard to extract or either of poor quality too
    :-(

    However, use this piece of code to see the principle for how to implement a telnet-state machine yourself. And read the books by W. Richard Stevens, Douglas Comer and Jon Snader.

    /Ole

    Sorry Ibrar...

    Reply
  • internet & networking Telnet - Ibrar Ahmad

    Posted by Legacy on 09/23/2002 12:00am

    Originally posted by: Klaus Scheibe

    Well done, Ibrar. Your code is fairly readable and worth reading. I am very in favor of it. I took the underlying idea and rewrote your program in C / Linux and C / HP-UX.

    Did you keep on development ?
    Do you meanwhile support other teminals ?

    Reply
  • ANSI implementation flaws

    Posted by Legacy on 05/26/2002 12:00am

    Originally posted by: QShot

    Hey excellent job on the telnet client. However the ansi implementation isn't very robust. I had to fix up a few things for it to work (&look) right with pine. These fixes should eliminate most problems people are seeing with your code.

    ===========================================================
    FIXES:
    ===========================================================
    *Problem level: annoying
    1.) added initialization of
    sa = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
    to ansi_set_screen_attribute.

    *Problem level: annoying
    2.) added
    int textattrib = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
    FillConsoleOutputAttribute(stdout1,textattrib,n,pos,&w);
    to ansi_erase_screen & ansi_erase_line

    *Problem level: annoying
    3.) Also, the client wasn't sending arrow keys correctly? I had to convert the input from getch() so that it would send
    ESC A, ESC B, ESC C, ESC D instead of 224 H, 224 K, 224 M, 224 P

    *Problem level: Very Bad
    4.) Pine kept sending ESC[@ so I had to change the DataProc for ansi so that the asc_esc1 state checked for
    if (data >= 64)
    {
    ...
    }

    Thanks,

    Aaron

    Reply
  • Creating server

    Posted by Legacy on 05/20/2002 12:00am

    Originally posted by: Devan Lippman

    Can I use this to create a telnet server?

    Reply
  • missing chars

    Posted by Legacy on 05/08/2002 12:00am

    Originally posted by: TTS

    Hi,

    I am able to compile and test your client. I do notice that 1st char is always truncated when receiving from the server. For example, when the server was sending 'Passowrd', the client only received 'assword'. Do you have any idea why ?? I kind of looking at the code but because it uses state machine, It is difficult to debug ?


    Thanks

    Reply
  • Console code

    Posted by Legacy on 04/03/2002 12:00am

    Originally posted by: Michael

    I would expect, but don't know for sure, that the console (conio.h) code is what is failing on Win98 particularly if you developed it under WinNT/2K/XP. This was a trap I fell into on one of my projects. I believed the MSDN docs that said conio worked reliably across DOS and NT. They don't work 100% the same.

    I'll try it out on my Win98 machine when I get a free minute.

    Reply
  • GREAT JOP ABRAR BUT .....

    Posted by Legacy on 03/21/2002 12:00am

    Originally posted by: DaWiZARD

    IT IS REALLY NO'T WORKING WITH WINDOWS 98 SECOND EDITION,
    
    THANK U

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • "Security" is the number one issue holding business leaders back from the cloud. But does the reality match the perception? Keeping data close to home, on premises, makes business and IT leaders feel inherently more secure. But the truth is, cloud solutions can offer companies real, tangible security advantages. Before you assume that on-site is the only way to keep data safe, it's worth taking a comprehensive approach to evaluating risks. Doing so can lead to big benefits.

  • Live Event Date: August 14, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT Data protection has long been considered "overhead" by many organizations in the past, many chalking it up to an insurance policy or an extended warranty you may never use. The realities of today makes data protection a must-have, as we live in a data-driven society -- the digital assets we create, share, and collaborate with others on must be managed and protected for many purposes. Check out this upcoming eSeminar and join Seagate Cloud …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds