#include <cli.h>
Inheritance diagram for PCLISocket:
Public Member Functions | |
Construction | |
PCLISocket (WORD port=0, const char *prompt=NULL, bool singleThreadForAll=false) | |
~PCLISocket () | |
Overrides from PCLI | |
virtual bool | Start (bool runInBackground=true) |
Start a command line interpreter. | |
virtual void | Stop () |
Stop and clean up command line interpreters. | |
virtual Context * | AddContext (Context *context=NULL) |
Add a command line interpreter context to the system. | |
virtual void | RemoveContext (Context *context) |
Remove the command line interpreter context. | |
Operations | |
bool | Listen (WORD port=0) |
Start listening socket. | |
WORD | GetPort () const |
Get the port we are listing on. | |
Protected Types | |
typedef std::map< PSocket *, Context * > | ContextMap_t |
Protected Member Functions | |
PDECLARE_NOTIFIER (PThread, PCLISocket, ThreadMain) | |
bool | HandleSingleThreadForAll () |
bool | HandleIncoming () |
virtual PTCPSocket * | CreateSocket () |
Protected Attributes | |
bool | m_singleThreadForAll |
PTCPSocket | m_listenSocket |
PThread * | m_thread |
ContextMap_t | m_contextBySocket |
This class allows for access and automatic creation of command line interpreter contexts from incoming TCP connections on a listening port.
typedef std::map<PSocket *, Context *> PCLISocket::ContextMap_t [protected] |
PCLISocket::PCLISocket | ( | WORD | port = 0 , |
|
const char * | prompt = NULL , |
|||
bool | singleThreadForAll = false | |||
) |
PCLISocket::~PCLISocket | ( | ) |
virtual Context* PCLISocket::AddContext | ( | Context * | context = NULL |
) | [virtual] |
Add a command line interpreter context to the system.
If context is NULL then CreateContext() is called to create one.
virtual PTCPSocket* PCLISocket::CreateSocket | ( | ) | [protected, virtual] |
Reimplemented in PCLITelnet.
WORD PCLISocket::GetPort | ( | ) | const [inline] |
Get the port we are listing on.
bool PCLISocket::HandleIncoming | ( | ) | [protected] |
bool PCLISocket::HandleSingleThreadForAll | ( | ) | [protected] |
bool PCLISocket::Listen | ( | WORD | port = 0 |
) |
Start listening socket.
PCLISocket::PDECLARE_NOTIFIER | ( | PThread | , | |
PCLISocket | , | |||
ThreadMain | ||||
) | [protected] |
virtual void PCLISocket::RemoveContext | ( | Context * | context | ) | [virtual] |
Remove the command line interpreter context.
The context thread is stopped, the channel closed and memory deleted.
virtual bool PCLISocket::Start | ( | bool | runInBackground = true |
) | [virtual] |
Start a command line interpreter.
This will start listening for incoming TCP connections and create/dispatch contexts to handle them.
runInBackground | Spawn a thread to read and interpret commands |
Reimplemented from PCLI.
virtual void PCLISocket::Stop | ( | ) | [virtual] |
Stop and clean up command line interpreters.
All the running contexts threads will be stopped, closing the channels and memory cleaned up.
The listening socket is also closed and the listener dispatch thread shut down.
Reimplemented from PCLI.
ContextMap_t PCLISocket::m_contextBySocket [protected] |
PTCPSocket PCLISocket::m_listenSocket [protected] |
bool PCLISocket::m_singleThreadForAll [protected] |
PThread* PCLISocket::m_thread [protected] |