PTLib  Version 2.18.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PHTTPListener Class Reference

Listener for incoming HTTP request with thread pool to handle those requests. More...

#include <http.h>

Inheritance diagram for PHTTPListener:
Collaboration diagram for PHTTPListener:

Classes

struct  Worker
 

Public Types

typedef PQueuedThreadPool< WorkerThreadPool
 

Public Member Functions

 PHTTPListener (unsigned maxWorkers=10)
 Construct new HTTP listsner with specified maximum number of threads in pool. More...
 
 ~PHTTPListener ()
 Shut down all listeners on destruction. More...
 
bool ListenForHTTP (WORD port, PSocket::Reusability reuse=PSocket::CanReuseAddress, unsigned queueSize=10)
 Start listening for HTTP connections. More...
 
bool ListenForHTTP (const PString &interfaces, WORD port, PSocket::Reusability reuse=PSocket::CanReuseAddress, unsigned queueSize=10)
 
void ShutdownListeners ()
 Shut down the listener socket, it's thread, and all threads in the pool. More...
 
bool IsListening () const
 Indicate is currently listening and processing requests. More...
 
WORD GetPort () const
 Get the port we are lkstening on. More...
 
virtual PChannelCreateChannelForHTTP (PChannel *channel)
 Call back to create transport socket, or TLS, channel. More...
 
virtual PHTTPServerCreateServerForHTTP ()
 
virtual void OnHTTPStarted (PHTTPServer &server)
 Callback when a new HTTP connection has begun. More...
 
virtual void OnHTTPEnded (PHTTPServer &server)
 Callback when an existing HTTP connection has ended. More...
 
const ThreadPoolGetThreadPool () const
 Get the thread pool in use for this HTTP listener. More...
 
ThreadPoolGetThreadPool ()
 
const PHTTPSpaceGetSpace () const
 Get the resource space for HTTP listener. More...
 
PHTTPSpaceGetSpace ()
 

Protected Member Functions

void ListenMain ()
 
 PDECLARE_MUTEX (m_httpServersMutex)
 

Protected Attributes

PHTTPSpace m_httpNameSpace
 
PString m_listenerInterfaces
 
WORD m_listenerPort
 
PThreadm_listenerThread
 
PSocketList m_httpListeningSockets
 
PList< PHTTPServerm_httpServers
 
ThreadPool m_threadPool
 

Detailed Description

Listener for incoming HTTP request with thread pool to handle those requests.

Member Typedef Documentation

Constructor & Destructor Documentation

PHTTPListener::PHTTPListener ( unsigned  maxWorkers = 10)

Construct new HTTP listsner with specified maximum number of threads in pool.

PHTTPListener::~PHTTPListener ( )

Shut down all listeners on destruction.

Member Function Documentation

virtual PChannel* PHTTPListener::CreateChannelForHTTP ( PChannel channel)
virtual

Call back to create transport socket, or TLS, channel.

Reimplemented in PSecureHTTPServiceProcess.

virtual PHTTPServer* PHTTPListener::CreateServerForHTTP ( )
virtual
WORD PHTTPListener::GetPort ( ) const
inline

Get the port we are lkstening on.

References m_httpListeningSockets.

const PHTTPSpace& PHTTPListener::GetSpace ( ) const
inline

Get the resource space for HTTP listener.

References m_httpNameSpace.

PHTTPSpace& PHTTPListener::GetSpace ( )
inline

References m_httpNameSpace.

const ThreadPool& PHTTPListener::GetThreadPool ( ) const
inline

Get the thread pool in use for this HTTP listener.

References m_threadPool.

ThreadPool& PHTTPListener::GetThreadPool ( )
inline

References m_threadPool.

bool PHTTPListener::IsListening ( ) const
inline

Indicate is currently listening and processing requests.

References m_httpListeningSockets.

bool PHTTPListener::ListenForHTTP ( WORD  port,
PSocket::Reusability  reuse = PSocket::CanReuseAddress,
unsigned  queueSize = 10 
)

Start listening for HTTP connections.

Parameters
portPort to listen on, zero picks a random one
reuseCan/Cant listen more than once.
queueSizeNumber of pending accepts that may be queued.
bool PHTTPListener::ListenForHTTP ( const PString interfaces,
WORD  port,
PSocket::Reusability  reuse = PSocket::CanReuseAddress,
unsigned  queueSize = 10 
)
Parameters
interfacesComma separated list of interfaces to listen on.
portPort to listen on, zero picks a random one
reuseCan/Cant listen more than once.
queueSizeNumber of pending accepts that may be queued.
void PHTTPListener::ListenMain ( )
protected
virtual void PHTTPListener::OnHTTPEnded ( PHTTPServer server)
virtual

Callback when an existing HTTP connection has ended.

Reimplemented in PHTTPServiceProcess.

virtual void PHTTPListener::OnHTTPStarted ( PHTTPServer server)
virtual

Callback when a new HTTP connection has begun.

Reimplemented in PSecureHTTPServiceProcess.

PHTTPListener::PDECLARE_MUTEX ( m_httpServersMutex  )
protected
void PHTTPListener::ShutdownListeners ( )

Shut down the listener socket, it's thread, and all threads in the pool.

Member Data Documentation

PSocketList PHTTPListener::m_httpListeningSockets
protected

Referenced by GetPort(), and IsListening().

PHTTPSpace PHTTPListener::m_httpNameSpace
protected

Referenced by GetSpace().

PList<PHTTPServer> PHTTPListener::m_httpServers
protected
PString PHTTPListener::m_listenerInterfaces
protected
WORD PHTTPListener::m_listenerPort
protected
PThread* PHTTPListener::m_listenerThread
protected
ThreadPool PHTTPListener::m_threadPool
protected

Referenced by GetThreadPool().


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