Logo Search packages:      
Sourcecode: pwlib version File versions  Download package

PTelnetSocket Class Reference

#include <telnet.h>

Inheritance diagram for PTelnetSocket:

PTCPSocket PIPSocket PSocket PChannel PObject

List of all members.

Detailed Description

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

Definition at line 112 of file telnet.h.

Comparison functions

enum  Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1 }
virtual Comparison CompareObjectMemoryDirect (const PObject &obj) const
bool operator!= (const PObject &obj) const
bool operator< (const PObject &obj) const
bool operator<= (const PObject &obj) const
bool operator== (const PObject &obj) const
bool operator> (const PObject &obj) const
bool operator>= (const PObject &obj) const

Error functions

enum  ErrorGroup { LastReadError, LastWriteError, LastGeneralError, NumErrorGroups }
enum  Errors {
  NoError, NotFound, FileExists, DiskFull,
  AccessDenied, DeviceInUse, BadParameter, NoMemory,
  NotOpen, Timeout, Interrupted, BufferTooSmall,
  Miscellaneous, ProtocolFailure, NumNormalisedErrors
Errors GetErrorCode (ErrorGroup group=NumErrorGroups) const
int GetErrorNumber (ErrorGroup group=NumErrorGroups) const
virtual PString GetErrorText (ErrorGroup group=NumErrorGroups) const
static PString GetErrorText (Errors lastError, int osError=0)

Socket establishment functions

enum  Reusability { CanReuseAddress, AddressIsExclusive }
 Flags to reuse of port numbers in Listen() function.
virtual BOOL Shutdown (ShutdownValue option)

Miscellaneous functions

enum  ShutdownValue { ShutdownRead = 0, ShutdownWrite = 1, ShutdownReadAndWrite = 2 }
void AbortCommandString ()
virtual BOOL Close ()
BOOL SendCommandString (const PString &command)
BOOL SetBufferSize (PINDEX newSize)

Scattered read/write functions

typedef std::vector< SliceVectorOfSlice
virtual BOOL Read (const VectorOfSlice &slices)
virtual BOOL Write (const VectorOfSlice &slices)

Run Time Type functions

virtual const char * GetClass (unsigned=0) const
virtual BOOL InternalIsDescendant (const char *clsName) const
BOOL IsClass (const char *cls) const
static const char * Class ()

Port/Service database functions

WORD GetPort () const
virtual WORD GetPortByService (const PString &service) const
PString GetService () const
virtual PString GetServiceByPort (WORD port) const
void SetPort (const PString &service)
void SetPort (WORD port)
static PString GetNameByProtocol (WORD proto)
static WORD GetPortByService (const char *protocol, const PString &service)
static WORD GetProtocolByName (const PString &name)
static PString GetServiceByPort (const char *protocol, WORD port)

I/O functions

virtual void PrintOn (ostream &strm) const
virtual void ReadFrom (istream &strm)
ostream & operator<< (ostream &strm, const PObject &obj)
istream & operator>> (istream &strm, PObject &obj)

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  PXBlockType { PXReadBlock, PXWriteBlock, PXAcceptBlock, PXConnectBlock }
enum  SubOptionCodes { SubOptionIs = 0, SubOptionSend = 1 }

Public Member Functions

virtual BOOL Accept (PSocket &socket)
virtual BOOL Connect (const Address &iface, WORD localPort, const Address &addr)
virtual BOOL Connect (const Address &iface, const Address &addr)
virtual BOOL Connect (WORD localPort, const Address &addr)
virtual BOOL Connect (const Address &addr)
virtual BOOL Connect (const PString &address)
PIPSocket::Address GetLastReceiveToAddress () const
virtual BOOL GetLocalAddress (Address &addr, WORD &port)
virtual BOOL GetLocalAddress (Address &addr)
PString GetLocalHostName ()
virtual PString GetName () const
virtual BOOL GetPeerAddress (Address &addr, WORD &port)
virtual BOOL GetPeerAddress (Address &addr)
PString GetPeerHostName ()
const PStringGetTerminalType () const
void GetWindowSize (WORD &width, WORD &height) const
BOOL IsOurOption (BYTE code) const
BOOL IsTheirOption (BYTE code) const
virtual void OnOutOfBand (const void *buf, PINDEX len)
 PLIST (InterfaceTable, InterfaceEntry)
 PLIST (RouteTable, RouteEntry)
 PTelnetSocket (const PString &address)
BOOL Read (void *buf, PINDEX len)
BOOL SendCommand (Command cmd, int opt=0)
virtual BOOL SendDo (BYTE option)
virtual BOOL SendDont (BYTE option)
BOOL SendSubOption (BYTE code, const BYTE *info, PINDEX len, int subCode=-1)
virtual BOOL SendWill (BYTE option)
virtual BOOL SendWont (BYTE option)
BOOL SetCaptureReceiveToAddress ()
void SetOurOption (BYTE code, BOOL state=TRUE)
void SetTerminalType (const PString &newType)
void SetTheirOption (BYTE code, BOOL state=TRUE)
void SetWindowSize (WORD width, WORD height)
BOOL Write (const void *buf, PINDEX len)
Overrides from class PObject.
virtual PObjectClone () const
Overrides from class PObject
virtual Comparison Compare (const PObject &obj) const
virtual PINDEX HashFunction () const
Information functions
virtual PChannelGetBaseReadChannel () const
virtual PChannelGetBaseWriteChannel () const
int GetHandle () const
virtual BOOL IsOpen () const
Reading functions
virtual PINDEX GetLastReadCount () const
PTimeInterval GetReadTimeout () const
virtual void OnReadComplete (void *buf, PINDEX len)
virtual BOOL ReadAsync (void *buf, PINDEX len)
BOOL ReadBlock (void *buf, PINDEX len)
virtual int ReadChar ()
PString ReadString (PINDEX len)
void SetReadTimeout (const PTimeInterval &time)
Writing functions
virtual PINDEX GetLastWriteCount () const
PTimeInterval GetWriteTimeout () const
virtual void OnWriteComplete (const void *buf, PINDEX len)
void SetWriteTimeout (const PTimeInterval &time)
virtual BOOL WriteAsync (const void *buf, PINDEX len)
BOOL WriteChar (int c)
BOOL WriteString (const PString &str)
Socket options functions
BOOL GetOption (int option, void *valuePtr, PINDEX valueSize, int level=SOL_SOCKET)
BOOL GetOption (int option, int &value, int level=SOL_SOCKET)
BOOL SetOption (int option, const void *valuePtr, PINDEX valueSize, int level=SOL_SOCKET)
BOOL SetOption (int option, int value, int level=SOL_SOCKET)
Overrides from class PSocket.
virtual BOOL Listen (const Address &bind, unsigned queueSize=5, WORD port=0, Reusability reuse=AddressIsExclusive)
virtual BOOL Listen (unsigned queueSize=5, WORD port=0, Reusability reuse=AddressIsExclusive)
New functions for class.
virtual BOOL WriteOutOfBand (const void *buf, PINDEX len)

Static Public Member Functions

static void ClearNameCache ()
static BOOL ConvertOSError (int libcReturnValue, Errors &lastError, int &osError)
static int GetDefaultIpAddressFamily ()
static PIPSocket::Address GetDefaultIpAny ()
static BOOL GetGatewayAddress (Address &addr)
static PString GetGatewayInterface ()
static BOOL GetHostAddress (const PString &hostname, Address &addr)
static BOOL GetHostAddress (Address &addr)
static PStringArray GetHostAliases (const Address &addr)
static PStringArray GetHostAliases (const PString &hostname)
static PString GetHostName (const Address &addr)
static PString GetHostName (const PString &hostname)
static PString GetHostName ()
static BOOL GetInterfaceTable (InterfaceTable &table)
static BOOL GetNetworkInterface (PIPSocket::Address &addr)
static BOOL GetRouteTable (RouteTable &table)
static BOOL IsLocalHost (const PString &hostname)
static void SetDefaultIpAddressFamily (int ipAdressFamily)
static void SetDefaultIpAddressFamilyV4 ()
Integer conversion functions
static DWORD Host2Net (DWORD v)
 Convert from host to network byte order.
static WORD Host2Net (WORD v)
 Convert from host to network byte order.
static DWORD Net2Host (DWORD v)
 Convert from network to host byte order.
static WORD Net2Host (WORD v)
 Convert from network to host byte order.
Multiple socket selection functions
static Errors Select (SelectList &read, SelectList &write, SelectList &except, const PTimeInterval &timeout)
static Errors Select (SelectList &read, SelectList &write, SelectList &except)
static Errors Select (SelectList &read, SelectList &write, const PTimeInterval &timeout)
static Errors Select (SelectList &read, SelectList &write)
static Errors Select (SelectList &read, const PTimeInterval &timeout)
static Errors Select (SelectList &read)
static int Select (PSocket &sock1, PSocket &sock2, const PTimeInterval &timeout)
static int Select (PSocket &sock1, PSocket &sock2)

Protected Member Functions

void Construct ()
virtual BOOL ConvertOSError (int libcReturnValue, ErrorGroup group=LastGeneralError)
virtual const char * GetProtocolName () const
virtual BOOL OnCommand (BYTE code)
virtual void OnDo (BYTE option)
virtual void OnDont (BYTE option)
virtual void OnSubOption (BYTE code, const BYTE *info, PINDEX len)
virtual void OnWill (BYTE option)
virtual void OnWont (BYTE option)
virtual BOOL OpenSocket (int ipAdressFamily)
virtual BOOL OpenSocket ()
BOOL os_accept (PSocket &listener, struct sockaddr *addr, PINDEX *size)
int os_close ()
BOOL os_connect (struct sockaddr *sin, PINDEX size)
BOOL os_recvfrom (void *buf, PINDEX len, int flags, struct sockaddr *from, PINDEX *fromlen)
BOOL os_sendto (const void *buf, PINDEX len, int flags, struct sockaddr *to, PINDEX tolen)
int os_socket (int af, int type, int proto)
int PXClose ()
BOOL PXSetIOBlock (PXBlockType type, const PTimeInterval &timeout)
int ReadCharWithTimeout (PTimeInterval &timeout)
BOOL ReceiveCommandString (int nextChar, const PString &reply, PINDEX &pos, PINDEX start)
BOOL SetErrorValues (Errors errorCode, int osError, ErrorGroup group=LastGeneralError)

Protected Attributes

PString channelName
BOOL debug
Errors lastErrorCode [NumErrorGroups+1]
 The platform independant error code.
int lastErrorNumber [NumErrorGroups+1]
 The operating system error number (eg as returned by errno).
PINDEX lastReadCount
 Number of byte last read by the Read() function.
PINDEX lastWriteCount
 Number of byte last written by the Write() function.
OptionInfo option [MaxOptions]
int os_handle
 The operating system file handle return by standard open() function.
WORD port
 Port to be used by the socket when opening the channel.
PXBlockType px_lastBlockType
PMutex px_selectMutex
PMutex px_threadMutex
PMutex px_writeMutex
PTimeInterval readTimeout
 Timeout for read operations.
PString terminalType
WORD windowHeight
WORD windowWidth
PTimeInterval writeTimeout
 Timeout for write operations.

Private Types

enum  State {
  StateNormal, StateCarriageReturn, StateIAC, StateDo,
  StateDont, StateWill, StateWont, StateSubNegotiations,

Private Member Functions

BOOL StartSend (const char *which, BYTE code)

Private Attributes

State state
PBYTEArray subOption
unsigned synchronising


struct  OptionInfo

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

Generated by  Doxygen 1.6.0   Back to index