#include <indchan.h>
Inheritance diagram for PIndirectChannel:
Public Member Functions | |
Construction | |
PIndirectChannel () | |
Create a new indirect channel without any channels to redirect to. | |
~PIndirectChannel () | |
Close the indirect channel, deleting read/write channels if desired. | |
Overrides from class PObject | |
Comparison | Compare (const PObject &obj) const |
Determine if the two objects refer to the same indirect channel. | |
Overrides from class PChannel | |
virtual PString | GetName () const |
Get the name of the channel. | |
virtual PBoolean | Close () |
Close the channel. | |
virtual PBoolean | IsOpen () const |
Determine if the channel is currently open and read and write operations can be executed on it. | |
virtual PBoolean | Read (void *buf, PINDEX len) |
Low level read from the channel. | |
virtual PBoolean | Write (const void *buf, PINDEX len) |
Low level write to the channel. | |
virtual PBoolean | Shutdown (ShutdownValue option) |
Close one or both of the data streams associated with a channel. | |
virtual bool | SetLocalEcho (bool localEcho) |
Set local echo mode. | |
virtual PChannel * | GetBaseReadChannel () const |
This function returns the eventual base channel for reading of a series of indirect channels provided by descendents of PIndirectChannel . | |
virtual PChannel * | GetBaseWriteChannel () const |
This function returns the eventual base channel for writing of a series of indirect channels provided by descendents of PIndirectChannel . | |
virtual PString | GetErrorText (ErrorGroup group=NumErrorGroups) const |
Get error message description. | |
Channel establish functions | |
PBoolean | Open (PChannel &channel) |
Set the channel for both read and write operations. | |
PBoolean | Open (PChannel *channel, PBoolean autoDelete=true) |
Set the channel for both read and write operations. | |
PBoolean | Open (PChannel *readChannel, PChannel *writeChannel, PBoolean autoDeleteRead=true, PBoolean autoDeleteWrite=true) |
Set the channel for both read and write operations. | |
PChannel * | GetReadChannel () const |
Get the channel used for read operations. | |
PBoolean | SetReadChannel (PChannel *channel, PBoolean autoDelete=true) |
Set the channel for read operations. | |
PChannel * | GetWriteChannel () const |
Get the channel used for write operations. | |
PBoolean | SetWriteChannel (PChannel *channel, PBoolean autoDelete=true) |
Set the channel for read operations. | |
Protected Member Functions | |
virtual PBoolean | OnOpen () |
This callback is executed when the Open() function is called with open channels. | |
Protected Attributes | |
PChannel * | readChannel |
Channel for read operations. | |
PBoolean | readAutoDelete |
Automatically delete read channel on destruction. | |
PChannel * | writeChannel |
Channel for write operations. | |
PBoolean | writeAutoDelete |
Automatically delete write channel on destruction. | |
PReadWriteMutex | channelPointerMutex |
Race condition prevention on closing channel. |
This allows for a protocol to operate through a "channel" mechanism and for its low level byte exchange (Read and Write) to operate via a completely different channel, eg TCP or Serial port etc.
PIndirectChannel::PIndirectChannel | ( | ) |
Create a new indirect channel without any channels to redirect to.
If an attempt to read or write is made before Open() is called the the functions will assert.
PIndirectChannel::~PIndirectChannel | ( | ) |
Close the indirect channel, deleting read/write channels if desired.
virtual PBoolean PIndirectChannel::Close | ( | ) | [virtual] |
Close the channel.
This will detach itself from the read and write channels and delete both of them if they are auto delete.
Reimplemented from PChannel.
Reimplemented in PFTPClient, PSMTPClient, PPOP3Client, PRFC822Channel, PSSLChannel, PVXMLSession, PVXMLChannel, XMPP::Transport, XMPP::Stream, and XMPP::C2S::TCPTransport.
Comparison PIndirectChannel::Compare | ( | const PObject & | obj | ) | const [virtual] |
Determine if the two objects refer to the same indirect channel.
This actually compares the channel pointers.
obj | Another indirect channel to compare against. |
Reimplemented from PChannel.
virtual PChannel* PIndirectChannel::GetBaseReadChannel | ( | ) | const [virtual] |
This function returns the eventual base channel for reading of a series of indirect channels provided by descendents of PIndirectChannel
.
The behaviour for this function is to return "this".
Reimplemented from PChannel.
virtual PChannel* PIndirectChannel::GetBaseWriteChannel | ( | ) | const [virtual] |
This function returns the eventual base channel for writing of a series of indirect channels provided by descendents of PIndirectChannel
.
The behaviour for this function is to return "this".
Reimplemented from PChannel.
virtual PString PIndirectChannel::GetErrorText | ( | ErrorGroup | group = NumErrorGroups |
) | const [virtual] |
Get error message description.
Return a string indicating the error message that may be displayed to the user. The error for the last I/O operation in this object is used.
group | Error group to get |
Reimplemented in PSSLChannel.
virtual PString PIndirectChannel::GetName | ( | ) | const [virtual] |
Get the name of the channel.
This is a combination of the channel pointers names (or simply the channel pointers name if the read and write channels are the same) or empty string if both null.
Reimplemented from PChannel.
PChannel* PIndirectChannel::GetReadChannel | ( | ) | const |
Get the channel used for read operations.
PChannel* PIndirectChannel::GetWriteChannel | ( | ) | const |
Get the channel used for write operations.
virtual PBoolean PIndirectChannel::IsOpen | ( | ) | const [virtual] |
Determine if the channel is currently open and read and write operations can be executed on it.
For example, in the PFile
class it returns if the file is currently open.
Reimplemented from PChannel.
Reimplemented in PVXMLChannel.
virtual PBoolean PIndirectChannel::OnOpen | ( | ) | [protected, virtual] |
This callback is executed when the Open() function is called with open channels.
It may be used by descendent channels to do any handshaking required by the protocol that channel embodies.
The default behaviour is to simply return true.
Reimplemented in PFTPClient, PFTPServer, PSMTPClient, PSMTPServer, PPOP3Client, PPOP3Server, PRFC822Channel, PSSLChannel, and XMPP::Stream.
PBoolean PIndirectChannel::Open | ( | PChannel * | readChannel, | |
PChannel * | writeChannel, | |||
PBoolean | autoDeleteRead = true , |
|||
PBoolean | autoDeleteWrite = true | |||
) |
Set the channel for both read and write operations.
This then checks that they are open and then calls the OnOpen() virtual function. If it in turn returns true then the Open() function returns success.
The channels pointed to by readChannel
and writeChannel
may be automatically deleted when the PIndirectChannel is destroyed or a new subchannel opened.
readChannel | Channel to be used for both read operations. |
writeChannel | Channel to be used for both write operations. |
autoDeleteRead | Automatically delete the read channel |
autoDeleteWrite | Automatically delete the write channel |
Set the channel for both read and write operations.
This then checks that they are open and then calls the OnOpen() virtual function. If it in turn returns true then the Open() function returns success.
The channel pointed to by channel
may be automatically deleted when the PIndirectChannel is destroyed or a new subchannel opened.
channel | Channel to be used for both read and write operations. |
autoDelete | Automatically delete the channel |
Set the channel for both read and write operations.
This then checks that they are open and then calls the OnOpen() virtual function. If it in turn returns true then the Open() function returns success.
channel | Channel to be used for both read and write operations. |
virtual PBoolean PIndirectChannel::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.
This will use the readChannel
pointer to actually do the read. If readChannel
is null the this asserts.
The GetErrorCode() function should be consulted after Read() returns false to determine what caused the failure.
buf | Pointer to a block of memory to receive the read bytes. |
len | Maximum number of bytes to read into the buffer. |
Reimplemented from PChannel.
Reimplemented in PDelayChannel, PInternetProtocol, PSSLChannel, and PVXMLChannel.
virtual bool PIndirectChannel::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.
Set the channel for read operations.
channel | Channel to be used for both read operations. |
autoDelete | Automatically delete the channel |
Set the channel for read operations.
channel | Channel to be used for both write operations. |
autoDelete | Automatically delete the channel |
virtual PBoolean PIndirectChannel::Shutdown | ( | ShutdownValue | option | ) | [virtual] |
Close one or both of the data streams associated with a channel.
The behavour here is to pass the shutdown on to its read and write channels.
option | Flag for shut down of read, write or both. |
Reimplemented in PSSLChannel.
virtual PBoolean PIndirectChannel::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.
This will use the writeChannel
pointer to actually do the write. If writeChannel
is null the this asserts.
The GetErrorCode() function should be consulted after Write() returns false to determine what caused the failure.
buf | Pointer to a block of memory to write. |
len | Number of bytes to write. |
Reimplemented from PChannel.
Reimplemented in PCLI::Context, PDelayChannel, PRFC822Channel, PInternetProtocol, PSSLChannel, PVXMLChannel, and XMPP::Stream.
PReadWriteMutex PIndirectChannel::channelPointerMutex [protected] |
Race condition prevention on closing channel.
PBoolean PIndirectChannel::readAutoDelete [protected] |
Automatically delete read channel on destruction.
PChannel* PIndirectChannel::readChannel [protected] |
Channel for read operations.
PBoolean PIndirectChannel::writeAutoDelete [protected] |
Automatically delete write channel on destruction.
PChannel* PIndirectChannel::writeChannel [protected] |
Channel for write operations.