Telnet | CodeGuru

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 […]

Written By
CodeGuru Staff
CodeGuru Staff
Sep 11, 2001
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More





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

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.