Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

PTelnetSocket Class Reference

#include <telnet.h>

Inheritance diagram for PTelnetSocket:

PTCPSocket PIPSocket PSocket PChannel PObject List of all members.

Public Types

enum  Command {
  IAC = 255, DONT = 254, DO = 253, WONT = 252,
  WILL = 251, SB = 250, GoAhead = 249, EraseLine = 248,
  EraseChar = 247, AreYouThere = 246, AbortOutput = 245, InterruptProcess = 244,
  Break = 243, DataMark = 242, NOP = 241, SE = 240,
  EndOfReccord = 239, AbortProcess = 238, SuspendProcess = 237, EndOfFile = 236
}
enum  Options {
  TransmitBinary = 0, EchoOption = 1, ReconnectOption = 2, SuppressGoAhead = 3,
  MessageSizeOption = 4, StatusOption = 5, TimingMark = 6, RCTEOption = 7,
  OutputLineWidth = 8, OutputPageSize = 9, CRDisposition = 10, HorizontalTabsStops = 11,
  HorizTabDisposition = 12, FormFeedDisposition = 13, VerticalTabStops = 14, VertTabDisposition = 15,
  LineFeedDisposition = 16, ExtendedASCII = 17, ForceLogout = 18, ByteMacroOption = 19,
  DataEntryTerminal = 20, SupDupProtocol = 21, SupDupOutput = 22, SendLocation = 23,
  TerminalType = 24, EndOfRecordOption = 25, TACACSUID = 26, OutputMark = 27,
  TerminalLocation = 28, Use3270RegimeOption = 29, UseX3PADOption = 30, WindowSize = 31,
  TerminalSpeed = 32, FlowControl = 33, LineModeOption = 34, XDisplayLocation = 35,
  EnvironmentOption = 36, AuthenticateOption = 37, EncriptionOption = 38, ExtendedOptionsList = 255,
  MaxOptions
}
enum  SubOptionCodes { SubOptionIs = 0, SubOptionSend = 1 }

Public Member Functions

 PTelnetSocket ()
 PTelnetSocket (const PString &address)
BOOL Read (void *buf, PINDEX len)
BOOL Write (const void *buf, PINDEX len)
virtual BOOL Connect (const PString &address)
virtual BOOL Accept (PSocket &socket)
virtual void OnOutOfBand (const void *buf, PINDEX len)
BOOL SendCommand (Command cmd, int opt=0)
virtual BOOL SendDo (BYTE option)
virtual BOOL SendDont (BYTE option)
virtual BOOL SendWill (BYTE option)
virtual BOOL SendWont (BYTE option)
BOOL SendSubOption (BYTE code, const BYTE *info, PINDEX len, int subCode=-1)
void SetOurOption (BYTE code, BOOL state=TRUE)
void SetTheirOption (BYTE code, BOOL state=TRUE)
BOOL IsOurOption (BYTE code) const
BOOL IsTheirOption (BYTE code) const
void SetTerminalType (const PString &newType)
const PStringGetTerminalType () const
void SetWindowSize (WORD width, WORD height)
void GetWindowSize (WORD &width, WORD &height) const

Protected Member Functions

void Construct ()
virtual void OnDo (BYTE option)
virtual void OnDont (BYTE option)
virtual void OnWill (BYTE option)
virtual void OnWont (BYTE option)
virtual void OnSubOption (BYTE code, const BYTE *info, PINDEX len)
virtual BOOL OnCommand (BYTE code)

Protected Attributes

OptionInfo option [MaxOptions]
PString terminalType
WORD windowWidth
WORD windowHeight
BOOL debug

Detailed Description

A TCP/IP socket for the TELNET high level protocol.


Member Enumeration Documentation

enum PTelnetSocket::Command
 

Enumeration values:
IAC 
DONT 
DO 
WONT 
WILL 
SB 
GoAhead 
EraseLine 
EraseChar 
AreYouThere 
AbortOutput 
InterruptProcess 
Break 
DataMark 
NOP 
SE 
EndOfReccord 
AbortProcess 
SuspendProcess 
EndOfFile 

enum PTelnetSocket::Options
 

Enumeration values:
TransmitBinary 
EchoOption 
ReconnectOption 
SuppressGoAhead 
MessageSizeOption 
StatusOption 
TimingMark 
RCTEOption 
OutputLineWidth 
OutputPageSize 
CRDisposition 
HorizontalTabsStops 
HorizTabDisposition 
FormFeedDisposition 
VerticalTabStops 
VertTabDisposition 
LineFeedDisposition 
ExtendedASCII 
ForceLogout 
ByteMacroOption 
DataEntryTerminal 
SupDupProtocol 
SupDupOutput 
SendLocation 
TerminalType 
EndOfRecordOption 
TACACSUID 
OutputMark 
TerminalLocation 
Use3270RegimeOption 
UseX3PADOption 
WindowSize 
TerminalSpeed 
FlowControl 
LineModeOption 
XDisplayLocation 
EnvironmentOption 
AuthenticateOption 
EncriptionOption 
ExtendedOptionsList 
MaxOptions 

enum PTelnetSocket::SubOptionCodes
 

Enumeration values:
SubOptionIs 
SubOptionSend 


Constructor & Destructor Documentation

PTelnetSocket::PTelnetSocket  ) 
 

PTelnetSocket::PTelnetSocket const PString address  ) 
 


Member Function Documentation

virtual BOOL PTelnetSocket::Accept PSocket socket  )  [virtual]
 

Open a socket to a remote host on the specified port number. This is an "accepting" socket. When a "listening" socket has a pending connection to make, this will accept a connection made by the "connecting" socket created to establish a link.

The port that the socket uses is the one used in the Listen() command of the socket parameter.

Note that this function will block until a remote system connects to the port number specified in the "listening" socket.

Returns:
TRUE if the channel was successfully opened.

Reimplemented from PTCPSocket.

virtual BOOL PTelnetSocket::Connect const PString address  )  [virtual]
 

Connect a socket to a remote host on the specified port number. This is typically used by the client or initiator of a communications channel. This connects to a "listening" socket at the other end of the communications channel.

The port number as defined by the object instance construction or the PIPSocket::SetPort() function.

Returns:
TRUE if the channel was successfully connected to the remote host.

Reimplemented from PIPSocket.

void PTelnetSocket::Construct  )  [protected]
 

Reimplemented from PChannel.

const PString& PTelnetSocket::GetTerminalType  )  const [inline]
 

void PTelnetSocket::GetWindowSize WORD &  width,
WORD &  height
const
 

BOOL PTelnetSocket::IsOurOption BYTE  code  )  const [inline]
 

Determine if the option on our side is enabled.

Returns:
TRUE if option is enabled.

BOOL PTelnetSocket::IsTheirOption BYTE  code  )  const [inline]
 

Determine if the option on their side is enabled.

Returns:
TRUE if option is enabled.

virtual BOOL PTelnetSocket::OnCommand BYTE  code  )  [protected, virtual]
 

This callback function is called by the system when it receives an telnet command that it does not do anything with.

The default action displays a message to the PError stream (when debug is TRUE) and returns TRUE;

Returns:
TRUE if next byte is not part of the command.

virtual void PTelnetSocket::OnDo BYTE  option  )  [protected, virtual]
 

This callback function is called by the system when it receives a DO request from the remote system.

The default action is to send a WILL for options that are understood by the standard TELNET class and a WONT for all others.

Returns:
TRUE if option is accepted.

virtual void PTelnetSocket::OnDont BYTE  option  )  [protected, virtual]
 

This callback function is called by the system when it receives a DONT request from the remote system.

The default action is to disable options that are understood by the standard TELNET class. All others are ignored.

virtual void PTelnetSocket::OnOutOfBand const void *  buf,
PINDEX  len
[virtual]
 

This is callback function called by the system whenever out of band data from the TCP/IP stream is received. A descendent class may interpret this data according to the semantics of the high level protocol.

The TELNET socket uses this for sychronisation.

Reimplemented from PTCPSocket.

virtual void PTelnetSocket::OnSubOption BYTE  code,
const BYTE *  info,
PINDEX  len
[protected, virtual]
 

This callback function is called by the system when it receives a sub-option command from the remote system.

virtual void PTelnetSocket::OnWill BYTE  option  )  [protected, virtual]
 

This callback function is called by the system when it receives a WILL request from the remote system.

The default action is to send a DO for options that are understood by the standard TELNET class and a DONT for all others.

virtual void PTelnetSocket::OnWont BYTE  option  )  [protected, virtual]
 

This callback function is called by the system when it receives a WONT request from the remote system.

The default action is to disable options that are understood by the standard TELNET class. All others are ignored.

BOOL PTelnetSocket::Read void *  buf,
PINDEX  len
[virtual]
 

Low level read from the channel. This function may block until the requested number of characters were read or the read timeout was reached. The GetLastReadCount() function returns the actual number of bytes read.

The GetErrorCode() function should be consulted after Read() returns FALSE to determine what caused the failure.

The TELNET channel intercepts and escapes commands in the data stream to implement the TELNET protocol.

Returns:
TRUE indicates that at least one character was read from the channel. FALSE means no bytes were read due to timeout or some other I/O error.

Reimplemented from PTCPSocket.

BOOL PTelnetSocket::SendCommand Command  cmd,
int  opt = 0
 

Send an escaped IAC command. The opt parameters meaning depends on the command being sent:

DO, DONT, WILL, WONT
opt is Options code.

AbortOutput
TRUE is flush buffer.

InterruptProcess, Break, AbortProcess, SuspendProcess
TRUE is synchronise.

Synchronises the TELNET streams, inserts the data mark into outgoing data stream and sends an out of band data to the remote to flush all data in the stream up until the syncronisation command.

Returns:
TRUE if the command was successfully sent.

virtual BOOL PTelnetSocket::SendDo BYTE  option  )  [virtual]
 

Send DO request.

Returns:
TRUE if the command was successfully sent.

virtual BOOL PTelnetSocket::SendDont BYTE  option  )  [virtual]
 

Send DONT command.

Returns:
TRUE if the command was successfully sent.

BOOL PTelnetSocket::SendSubOption BYTE  code,
const BYTE *  info,
PINDEX  len,
int  subCode = -1
 

Send a sub-option with the information given.

Returns:
TRUE if the command was successfully sent.

virtual BOOL PTelnetSocket::SendWill BYTE  option  )  [virtual]
 

Send WILL request.

Returns:
TRUE if the command was successfully sent.

virtual BOOL PTelnetSocket::SendWont BYTE  option  )  [virtual]
 

Send WONT command.

Returns:
TRUE if the command was successfully sent.

void PTelnetSocket::SetOurOption BYTE  code,
BOOL  state = TRUE
[inline]
 

Set if the option on our side is possible, this does not mean it is set it only means that in response to a DO we WILL rather than WONT.

void PTelnetSocket::SetTerminalType const PString newType  ) 
 

void PTelnetSocket::SetTheirOption BYTE  code,
BOOL  state = TRUE
[inline]
 

Set if the option on their side is desired, this does not mean it is set it only means that in response to a WILL we DO rather than DONT.

void PTelnetSocket::SetWindowSize WORD  width,
WORD  height
 

BOOL PTelnetSocket::Write const void *  buf,
PINDEX  len
[virtual]
 

Low level write to the channel. This function will block until the requested number of characters are written or the write timeout is reached. The GetLastWriteCount() function returns the actual number of bytes written.

The GetErrorCode() function should be consulted after Write() returns FALSE to determine what caused the failure.

The TELNET channel intercepts and escapes commands in the data stream to implement the TELNET protocol.

Returns TRUE if at least len bytes were written to the channel.

Reimplemented from PTCPSocket.


Member Data Documentation

BOOL PTelnetSocket::debug [protected]
 

OptionInfo PTelnetSocket::option[MaxOptions] [protected]
 

PString PTelnetSocket::terminalType [protected]
 

WORD PTelnetSocket::windowHeight [protected]
 

WORD PTelnetSocket::windowWidth [protected]
 


The documentation for this class was generated from the following file:
Generated on Sat Jul 24 15:36:00 2004 for PWLib by doxygen 1.3.7