PTLib Version 2.12.9

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PTelnetSocket Class Reference

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

`#include <telnet.h>`

Inheritance diagram for PTelnetSocket:
[legend]
Collaboration diagram for PTelnetSocket:
[legend]

## Classes
struct | OptionInfo

## 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, EncryptionOption = 38, ExtendedOptionsList = 255, MaxOptions }
enum | SubOptionCodes { SubOptionIs = 0, SubOptionSend = 1 }

## Public Member Functions
| PTelnetSocket ()
| PTelnetSocket (const PString &address)
PBoolean | Read (void *buf, PINDEX len)
| Low level read from the channel. More...
PBoolean | Write (const void *buf, PINDEX len)
| Low level write to the channel. More...
virtual bool | SetLocalEcho (bool localEcho)
| Set local echo mode. More...
virtual PBoolean | Connect (const PString &address)
| Connect a socket to a remote host on the specified port number. More...
virtual PBoolean | Accept (PSocket &socket)
| Open a socket to a remote host on the specified port number. More...
virtual void | OnOutOfBand (const void *buf, PINDEX len)
| This is callback function called by the system whenever out of band data from the TCP/IP stream is received. More...
PBoolean | SendCommand (Command cmd, int opt=0)
| Send an escaped IAC command. More...
virtual PBoolean | SendDo (BYTE option)
| Send DO request. More...
virtual PBoolean | SendDont (BYTE option)
| Send DONT command. More...
virtual PBoolean | SendWill (BYTE option)
| Send WILL request. More...
virtual PBoolean | SendWont (BYTE option)
| Send WONT command. More...
PBoolean | SendSubOption (BYTE code, const BYTE *info, PINDEX len, int subCode=-1)
| Send a sub-option with the information given. More...
void | SetOurOption (BYTE code, PBoolean state=true)
| 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. More...
void | SetTheirOption (BYTE code, PBoolean state=true)
| 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. More...
PBoolean | IsOurOption (BYTE code) const
| Determine if the option on our side is enabled. More...
PBoolean | IsTheirOption (BYTE code) const
| Determine if the option on their side is enabled. More...
void | SetTerminalType (const PString &newType)
const PString & | GetTerminalType () const
void | SetWindowSize (WORD width, WORD height)
void | GetWindowSize (WORD &width, WORD &height) const
Public Member Functions inherited from PTCPSocket
| PTCPSocket (WORD port=0)
| Create a TCP/IP protocol socket channel. More...
| PTCPSocket (const PString &service)
| PTCPSocket (const PString &address, WORD port)
| PTCPSocket (const PString &address, const PString &service)
| PTCPSocket (PSocket &socket)
| PTCPSocket (PTCPSocket &tcpSocket)
virtual PObject * | Clone () const
| Create a copy of the class on the heap. More...
virtual PBoolean | WriteOutOfBand (const void *buf, PINDEX len)
| Write out of band data from the TCP/IP stream. More...
Public Member Functions inherited from PIPSocket
virtual bool | InternalGetLocalAddress (AddressAndPort &addrAndPort)
virtual bool | InternalGetPeerAddress (AddressAndPort &addrAndPort)
virtual PBoolean | Connect (const Address &addr)
virtual PBoolean | Connect (WORD localPort, const Address &addr)
virtual PBoolean | Connect (const Address &iface, const Address &addr)
virtual PBoolean | Connect (const Address &iface, WORD localPort, const Address &addr)
virtual PBoolean | Listen (unsigned queueSize=5, WORD port=0, Reusability reuse=AddressIsExclusive)
| Listen on a socket for a remote host on the specified port number. More...
virtual PBoolean | Listen (const Address &bind, unsigned queueSize=5, WORD port=0, Reusability reuse=AddressIsExclusive)
virtual bool | SetQoS (const QoS &qos)
| Set the current Quality of Service. More...
const QoS & | GetQoS () const
| Get the current Quality of Service. More...
virtual PString | GetName () const
| Get the platform and I/O channel type name of the channel. More...
PString | GetLocalAddress ()
| Get the Internet Protocol address and port for the local host. More...
bool | GetLocalAddress (Address &addr)
bool | GetLocalAddress (Address &addr, WORD &port)
bool | GetLocalAddress (AddressAndPort &addr)
PString | GetPeerAddress ()
| Get the Internet Protocol address for the peer host and port the socket is connected to. More...
bool | GetPeerAddress (Address &addr)
bool | GetPeerAddress (Address &addr, WORD &port)
bool | GetPeerAddress (AddressAndPort &addr)
PString | GetLocalHostName ()
| Get the host name for the local host. More...
PString | GetPeerHostName ()
| Get the host name for the peer host the socket is connected to. More...
| PARRAY (RouteTable, RouteEntry)
| PARRAY (InterfaceTable, InterfaceEntry)
| P_DECLARE_ENUM (QoSType, BackgroundQoS, BestEffortQoS, ExcellentEffortQoS, CriticalQoS, VideoQoS, VoiceQoS, ControlQoS)
| The types of QoS supported, based on IEEE P802.1p TrafficClass parameter. More...
Public Member Functions inherited from PSocket
| ~PSocket ()
PBoolean | SetOption (int option, int value, int level=SOL_SOCKET)
| Set options on the socket. More...
PBoolean | SetOption (int option, const void *valuePtr, PINDEX valueSize, int level=SOL_SOCKET)
| Set options on the socket. More...
PBoolean | GetOption (int option, int &value, int level=SOL_SOCKET)
| Get options on the socket. More...
PBoolean | GetOption (int option, void *valuePtr, PINDEX valueSize, int level=SOL_SOCKET)
| Get options on the socket. More...
virtual bool | Read (Slice *slices, size_t sliceCount)
| Low level scattered read from the channel. More...
virtual bool | Write (const Slice *slices, size_t sliceCount)
| Low level scattered write to the channel. More...
virtual PBoolean | Shutdown (ShutdownValue option)
| Close one or both of the data streams associated with a socket. More...
virtual WORD | GetPortByService (const PString &service) const
| Get the port number for the specified service name. More...
virtual PString | GetServiceByPort (WORD port) const
| Get the service name from the port number. More...
void | SetPort (WORD port)
| Set the port number for the channel. More...
void | SetPort (const PString &service)
| Set the port number for the channel. More...
WORD | GetPort () const
| Get the port the TCP socket channel object instance is using. More...
PString | GetService () const
| Get a service name for the port number the TCP socket channel object instance is using. More...
Public Member Functions inherited from PChannel
PBoolean | SetErrorValues (Errors errorCode, int osError, ErrorGroup group=LastGeneralError)
| Set error values to those specified. More...
virtual Comparison | Compare (const PObject &obj) const
| Get the relative rank of the two strings. More...
virtual PINDEX | HashFunction () const
| Calculate a hash value for use in sets and dictionaries. More...
virtual PBoolean | IsOpen () const
| Determine if the channel is currently open. More...
P_INT_PTR | GetHandle () const
| Get the integer operating system handle for the channel. More...
virtual PChannel * | GetBaseReadChannel () const
| Get the base channel of channel indirection using PIndirectChannel. More...
virtual PChannel * | GetBaseWriteChannel () const
| Get the base channel of channel indirection using PIndirectChannel. More...
void | SetReadTimeout (const PTimeInterval &time)
| Set the timeout for read operations. More...
PTimeInterval | GetReadTimeout () const
| Get the timeout for read operations. More...
virtual PINDEX | GetLastReadCount () const
| Get the number of bytes read by the last Read() call. More...
virtual int | ReadChar ()
| Read a single 8 bit byte from the channel. More...
PBoolean | ReadBlock (void *buf, PINDEX len)
| Read len bytes into the buffer from the channel. More...
PString | ReadString (PINDEX len)
| Read `len` character into a string from the channel. More...
void | SetWriteTimeout (const PTimeInterval &time)
| Set the timeout for write operations to complete. More...
PTimeInterval | GetWriteTimeout () const
| Get the timeout for write operations to complete. More...
virtual PBoolean | Write (const void *buf, PINDEX len, const void *)
| Low level write to the channel with marker. More...
virtual PINDEX | GetLastWriteCount () const
| Get the number of bytes written by the last Write() call. More...
PBoolean | WriteChar (int c)
| Write a single character to the channel. More...
PBoolean | WriteString (const PString &str)
| Write a string to the channel. More...
| ~PChannel ()
| Close down the channel. More...
Errors | GetErrorCode (ErrorGroup group=NumErrorGroups) const
| Get normalised error code. More...
int | GetErrorNumber (ErrorGroup group=NumErrorGroups) const
| Get OS errro code. More...
virtual PString | GetErrorText (ErrorGroup group=NumErrorGroups) const
| Get error message description. More...
virtual bool | ReadAsync (AsyncContext &context)
| Begin an asynchronous read from channel. More...
virtual void | OnReadComplete (AsyncContext &context)
| User callback function for when a `ReadAsync()` call has completed or timed out. More...
virtual bool | WriteAsync (AsyncContext &context)
| Begin an asynchronous write from channel. More...
virtual void | OnWriteComplete (AsyncContext &context)
| User callback function for when a WriteAsync() call has completed or timed out. More...
virtual PBoolean | Close ()
| Close the channel, shutting down the link to the data source. More...
virtual bool | FlowControl (const void *flowData)
| Flow Control information Pass data to the channel for flowControl determination. More...
PBoolean | SetBufferSize (PINDEX newSize)
| Set the iostream buffer size for reads and writes. More...
PBoolean | SendCommandString (const PString &command)
| Send a command meta-string. More...
void | AbortCommandString ()
| Abort a command string that is in progress. More...
Public Member Functions inherited from PObject
unsigned | GetTraceContextIdentifier () const
| Get PTRACE context identifier. More...
void | SetTraceContextIdentifier (unsigned id)
void | GetTraceContextIdentifier (PObject &obj)
void | GetTraceContextIdentifier (PObject *obj)
void | SetTraceContextIdentifier (const PObject &obj)
void | SetTraceContextIdentifier (const PObject *obj)
virtual | ~PObject ()
template<class CLS >
CLS * | CloneAs () const
| As for Clone() but converts to specified type. More...
virtual const char * | GetClass (unsigned ancestor=0) const
| Get the current dynamic type of the object instance. More...
PBoolean | IsClass (const char *cls) const
virtual PBoolean | InternalIsDescendant (const char *clsName) const
| Determine if the dynamic type of the current instance is a descendent of the specified class. More...
__inline const PObject * | PTraceObjectInstance () const
virtual Comparison | CompareObjectMemoryDirect (const PObject &obj) const
| Determine the byte wise comparison of two objects. More...
bool | operator== (const PObject &obj) const
| Compare the two objects. More...
bool | operator!= (const PObject &obj) const
| Compare the two objects. More...
bool | operator< (const PObject &obj) const
| Compare the two objects. More...
bool | operator> (const PObject &obj) const
| Compare the two objects. More...
bool | operator<= (const PObject &obj) const
| Compare the two objects. More...
bool | operator>= (const PObject &obj) const
| Compare the two objects. More...
virtual void | PrintOn (ostream &strm) const
| Output the contents of the object to the stream. More...
virtual void | ReadFrom (istream &strm)
| Input the contents of the object from the stream. More...

## Protected Member Functions
void | Construct ()
virtual void | OnDo (BYTE option)
| This callback function is called by the system when it receives a DO request from the remote system. More...
virtual void | OnDont (BYTE option)
| This callback function is called by the system when it receives a DONT request from the remote system. More...
virtual void | OnWill (BYTE option)
| This callback function is called by the system when it receives a WILL request from the remote system. More...
virtual void | OnWont (BYTE option)
| This callback function is called by the system when it receives a WONT request from the remote system. More...
virtual void | OnSubOption (BYTE code, const BYTE *info, PINDEX len)
| This callback function is called by the system when it receives a sub-option command from the remote system. More...
virtual PBoolean | OnCommand (BYTE code)
| This callback function is called by the system when it receives an telnet command that it does not do anything with. More...
Protected Member Functions inherited from PTCPSocket
virtual PBoolean | OpenSocket ()
virtual PBoolean | OpenSocket (int ipAdressFamily)
| Open an IPv4 or IPv6 socket. More...
virtual bool | InternalListen (const Address &bind, unsigned queueSize, WORD port, Reusability reuse)
virtual const char * | GetProtocolName () const
| This function returns the protocol name for the socket type. More...
Protected Member Functions inherited from PIPSocket
| PIPSocket ()
| Create a new Internet Protocol socket based on the port number specified. More...
Protected Member Functions inherited from PSocket
| PSocket ()
int | os_close ()
int | os_socket (int af, int type, int proto)
PBoolean | os_connect (struct sockaddr *sin, socklen_t size)
PBoolean | os_vread (Slice *slices, size_t sliceCount, int flags, struct sockaddr *from, socklen_t *fromlen)
PBoolean | os_vwrite (const Slice *slices, size_t sliceCount, int flags, struct sockaddr *to, socklen_t tolen)
PBoolean | os_accept (PSocket &listener, struct sockaddr *addr, socklen_t *size)
Protected Member Functions inherited from PChannel
| PChannel (const PChannel &)
PChannel & | operator= (const PChannel &)
virtual PBoolean | ConvertOSError (P_INT_PTR libcReturnValue, ErrorGroup group=LastGeneralError)
| Convert an operating system error into platform independent error. More...
int | ReadCharWithTimeout (PTimeInterval &timeout)
| Read a character with specified timeout. More...
PBoolean | ReceiveCommandString (int nextChar, const PString &reply, PINDEX &pos, PINDEX start)
PBoolean | PXSetIOBlock (PXBlockType type, const PTimeInterval &timeout)
P_INT_PTR | GetOSHandleAsInt () const
int | PXClose ()
| PChannel ()
| Create the channel. More...
Protected Member Functions inherited from PObject
| PObject ()
| Constructor for PObject, made protected so cannot ever create one on its own. More...

## Protected Attributes
OptionInfo | option [MaxOptions]
PString | terminalType
WORD | windowWidth
WORD | windowHeight

## Additional Inherited Members
Static Public Member Functions inherited from PIPSocket
static int | GetDefaultIpAddressFamily ()
| Set the default IP address familly. More...
static void | SetDefaultIpAddressFamily (int ipAdressFamily)
static void | SetDefaultIpAddressFamilyV4 ()
static const PIPSocket::Address & | GetDefaultIpAny ()
static const PIPSocket::Address & | GetInvalidAddress ()
static void | SetSuppressCanonicalName (bool suppress)
| Set flag for suppress getting canonical name when doing lookup via hostname. More...
static bool | GetSuppressCanonicalName ()
| Get flag for suppress getting canonical name when doing lookup via hostname. More...
static PString | GetHostName ()
| Get the "official" host name for the host specified or if none, the host this process is running on. More...
static PString | GetHostName (const PString &hostname)
static PString | GetHostName (const Address &addr)
static PBoolean | GetHostAddress (Address &addr)
| Get the Internet Protocol address for the specified host, or if none specified, for the host this process is running on. More...
static PBoolean | GetHostAddress (const PString &hostname, Address &addr)
static PStringArray | GetHostAliases (const PString &hostname)
| Get the alias host names for the specified host. More...
static PStringArray | GetHostAliases (const Address &addr)
static PBoolean | IsLocalHost (const PString &hostname)
| Determine if the specified host is actually the local machine. More...
static void | ClearNameCache ()
| Clear the name (DNS) cache. More...
static PBoolean | GetRouteTable (RouteTable &table)
| Get the systems route table. More...
static RouteTableDetector * | CreateRouteTableDetector ()
| Create an object that can wait for a change in the route table or active network interfaces. More...
static PBoolean | GetInterfaceTable (InterfaceTable &table, PBoolean includeDown=false)
| Get a list of all interfaces. More...
static PString | GetInterface (const Address &addr)
| Get the interface name for the specified local IP address. More...
static Address | GetInterfaceAddress (const PString &ifName, unsigned version=4)
| Get the interface name for the specified local IP address. More...
static Address | GetNetworkInterface (unsigned version=4)
| Get the address of the first interface to the "Internet". More...
static Address | GetGatewayAddress (unsigned version=4)
| Get the IP address that is being used as the gateway, that is, the computer that packets on the default route will be sent. More...
static PString | GetGatewayInterface (unsigned version=4)
| Get the name for the interface that is being used as the gateway, that is, the interface that packets on the default route will be sent. More...
static Address | GetGatewayInterfaceAddress (unsigned version=4)
| Get the IP address for the interface that is being used as the gateway, that is, the interface that packets on the default route will be sent. More...
static Address | GetRouteInterfaceAddress (Address remoteAddress)
| Get the interface address that will be used to reach the specified remote address. More...
Static Public Member Functions inherited from PSocket
static int | Select (PSocket &sock1, PSocket &sock2)
| Select a socket with available data. More...
static int | Select (PSocket &sock1, PSocket &sock2, const PTimeInterval &timeout)
| Select a socket with available data. More...
static Errors | Select (SelectList &read)
| Select a socket with available data. More...
static Errors | Select (SelectList &read, const PTimeInterval &timeout)
| Select a socket with available data. More...
static Errors | Select (SelectList &read, SelectList &write)
| Select a socket with available data. More...
static Errors | Select (SelectList &read, SelectList &write, const PTimeInterval &timeout)
| Select a socket with available data. More...
static Errors | Select (SelectList &read, SelectList &write, SelectList &except)
| Select a socket with available data. More...
static Errors | Select (SelectList &read, SelectList &write, SelectList &except, const PTimeInterval &timeout)
| Select a socket with available data. More...
static WORD | Host2Net (WORD v)
| Convert from host to network byte order. More...
static DWORD | Host2Net (DWORD v)
| Convert from host to network byte order. More...
static WORD | Net2Host (WORD v)
| Convert from network to host byte order. More...
static DWORD | Net2Host (DWORD v)
| Convert from network to host byte order. More...
static WORD | GetProtocolByName (const PString &name)
| Get the number of the protocol associated with the specified name. More...
static PString | GetNameByProtocol (WORD proto)
| Get the name of the protocol number specified. More...
static WORD | GetPortByService (const char *protocol, const PString &service)
| Get the port number for the specified service name. More...
static PString | GetServiceByPort (const char *protocol, WORD port)
| Get the service name from the port number. More...
Friends inherited from PObject

## Detailed Description

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

## Member Enumeration Documentation

enum PTelnetSocket::Command

Enumerator
IAC | Interpret As Command - escape character.
DONT | You are not to use option.
DO | Request to use option.
WONT | Refuse use of option.
WILL | Accept the use of option.
SB | Subnegotiation begin.
GoAhead | Function GA, you may reverse the line.
EraseLine | Function EL, erase the current line.
EraseChar | Function EC, erase the current character.
AreYouThere | Function AYT, are you there?
AbortOutput | Function AO, abort output stream.
InterruptProcess | Function IP, interrupt process, permanently.
Break | NVT character break.
DataMark | Marker for connection cleaning.
NOP | No operation.
SE | Subnegotiation end.
EndOfReccord | End of record for transparent mode.
AbortProcess | Abort the entire process.
SuspendProcess | Suspend the process.
EndOfFile | End of file marker.

enum PTelnetSocket::Options

Enumerator
TransmitBinary | Assume binary 8 bit data is transferred.
EchoOption | Automatically echo characters sent.
ReconnectOption | Prepare to reconnect.
SuppressGoAhead | Do not use the GA protocol.
MessageSizeOption | Negatiate approximate message size.
StatusOption | Status packets are understood.
TimingMark | Marker for synchronisation.
RCTEOption | Remote controlled transmission and echo.
OutputLineWidth | Negotiate about output line width.
OutputPageSize | Negotiate about output page size.
CRDisposition | Negotiate about CR disposition.
HorizontalTabsStops | Negotiate about horizontal tabstops.
HorizTabDisposition | Negotiate about horizontal tab disposition.
FormFeedDisposition | Negotiate about formfeed disposition.
VerticalTabStops | Negotiate about vertical tab stops.
VertTabDisposition | Negotiate about vertical tab disposition.
LineFeedDisposition | Negotiate about output LF disposition.
ExtendedASCII | Extended ascic character set.
ForceLogout | Force logout.
ByteMacroOption | Byte macro.
DataEntryTerminal | data entry terminal.
SupDupProtocol | supdup protocol.
SupDupOutput | supdup output.
SendLocation | Send location.
TerminalType | Provide terminal type information.
EndOfRecordOption | Record boundary marker.
TACACSUID | TACACS user identification.
OutputMark | Output marker or banner text.
TerminalLocation | Terminals physical location information.
Use3270RegimeOption | 3270 regime.
UseX3PADOption | X.3 PAD.
WindowSize | NAWS - Negotiate About Window Size.
TerminalSpeed | Provide terminal speed information.
FlowControl | Remote flow control.
LineModeOption | Terminal in line mode option.
XDisplayLocation | X Display location.
EnvironmentOption | Provide environment information.
AuthenticateOption | Authenticate option.
EncriptionOption | Encryption option.
EncryptionOption | Duplicate to fix spelling mistake and remain backwards compatible.
ExtendedOptionsList | Code for extended options.
MaxOptions |

enum PTelnetSocket::SubOptionCodes

Enumerator
SubOptionIs | Sub-option is...
SubOptionSend | Request to send option.

## Constructor & Destructor Documentation

PTelnetSocket::PTelnetSocket | ( |  | ) |

PTelnetSocket::PTelnetSocket | ( | const PString & | address | ) |

Parameters

  address | Address of remote machine to connect to.

## Member Function Documentation

virtual PBoolean 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.

Parameters

  socket | Listening socket making the connection.

Reimplemented from PTCPSocket.

virtual PBoolean 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.

Parameters

  address | Address of remote machine to connect to.

Reimplemented from PIPSocket.

void PTelnetSocket::Construct | ( |  | ) |
| protected

const PString& PTelnetSocket::GetTerminalType | ( |  | ) | const
| inline

References terminalType.

void PTelnetSocket::GetWindowSize | ( | WORD & | width,
|  | WORD & | height
| ) |  | const

Parameters

  width | Old window width.
  height | Old window height.

PBoolean PTelnetSocket::IsOurOption | ( | BYTE | code | ) | const
| inline

Determine if the option on our side is enabled.

Returns
  true if option is enabled.

Parameters

  code | Option to check.

References PTelnetSocket::OptionInfo::IsYes, option, and PTelnetSocket::OptionInfo::ourState.

PBoolean PTelnetSocket::IsTheirOption | ( | BYTE | code | ) | const
| inline

Determine if the option on their side is enabled.

Returns
  true if option is enabled.

Parameters

  code | Option to check.

References PTelnetSocket::OptionInfo::IsYes, option, and PTelnetSocket::OptionInfo::theirState.

virtual PBoolean 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.

Parameters

  code | Code received that could not be precessed.

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.

Parameters

  option | Option to DO

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.

Parameters

  option | Option to DONT

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.

Parameters

  buf | Data to be received as URGENT TCP data.
  len | Number of bytes pointed to by `buf`.

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.

Parameters

  code | Option code for sub-option data.
  info | Extra information being sent in the sub-option.
  len | Number of extra bytes.

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.

Parameters

  option | Option to WILL

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.

Parameters

  option | Option to WONT

PBoolean 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.

Parameters

  buf | Pointer to a block of memory to receive the read bytes.
  len | Maximum number of bytes to read into the buffer.

Reimplemented from PTCPSocket.

PBoolean 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.

Parameters

  cmd | Command code to send
  opt | Option for command code.

virtual PBoolean PTelnetSocket::SendDo | ( | BYTE | option | ) |
| virtual

Send DO request.

Returns
  true if the command was successfully sent.

Parameters

  option | Option to DO

virtual PBoolean PTelnetSocket::SendDont | ( | BYTE | option | ) |
| virtual

Send DONT command.

Returns
  true if the command was successfully sent.

Parameters

  option | Option to DONT

PBoolean 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.

Parameters

  code | Suboptions option code.
  info | Information to send.
  len | Length of information.
  subCode | Suboptions sub-code, -1 indicates no sub-code.

virtual PBoolean PTelnetSocket::SendWill | ( | BYTE | option | ) |
| virtual

Send WILL request.

Returns
  true if the command was successfully sent.

Parameters

  option | Option to WILL

virtual PBoolean PTelnetSocket::SendWont | ( | BYTE | option | ) |
| virtual

Send WONT command.

Returns
  true if the command was successfully sent.

Parameters

  option | Option to WONT

virtual bool PTelnetSocket::SetLocalEcho | ( | bool | localEcho | ) |
| virtual

Set local echo mode.

For some classes of channel, e.g. PConsoleChannel, data read by this channel is automatically echoed. This disables the function so things like password entry can work.

Default behaviour does nothing and return true if the channel is open.

Reimplemented from PChannel.

void PTelnetSocket::SetOurOption | ( | BYTE | code,
|  | PBoolean | 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.

Parameters

  code | Option to check.
  state | New state for for option.

References option, and PTelnetSocket::OptionInfo::weCan.

void PTelnetSocket::SetTerminalType | ( | const PString & | newType | ) |

Parameters

  newType | New terminal type description string.

void PTelnetSocket::SetTheirOption | ( | BYTE | code,
|  | PBoolean | 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.

Parameters

  code | Option to check.
  state | New state for for option.

References option, and PTelnetSocket::OptionInfo::theyShould.

void PTelnetSocket::SetWindowSize | ( | WORD | width,
|  | WORD | height
| ) |  |

Parameters

  width | New window width.
  height | New window height.

PBoolean 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.

Parameters

  buf | Pointer to a block of memory to write.
  len | Number of bytes to write.

Reimplemented from PTCPSocket.

## Member Data Documentation

OptionInfo PTelnetSocket::option[MaxOptions]
| protected

Referenced by IsOurOption(), IsTheirOption(), SetOurOption(), and SetTheirOption().

PString PTelnetSocket::terminalType
| protected

Referenced by GetTerminalType().

WORD PTelnetSocket::windowHeight
| protected

WORD PTelnetSocket::windowWidth
| protected

The documentation for this class was generated from the following file:

- telnet.h