OPAL  Version 3.18.8
OpalListenerTCP Class Reference

#include <transports.h>

Inheritance diagram for OpalListenerTCP:
Collaboration diagram for OpalListenerTCP:

Public Member Functions

Construction
 OpalListenerTCP (OpalEndPoint &endpoint, PIPSocket::Address binding=PIPSocket::GetDefaultIpAny(), WORD port=0, PBoolean exclusive=true)
 
 OpalListenerTCP (OpalEndPoint &endpoint, const OpalTransportAddress &binding, OpalTransportAddress::BindOptions option)
 
 ~OpalListenerTCP ()
 
Overrides from OpalListener
virtual bool Open (const AcceptHandler &acceptHandler, ThreadMode mode=SpawnNewThreadMode)
 
virtual bool IsOpen () const
 
virtual void Close ()
 
virtual OpalTransportAccept (const PTimeInterval &timeout)
 
virtual OpalTransportCreateTransport (const OpalTransportAddress &localAddress, const OpalTransportAddress &remoteAddress) const
 
- Public Member Functions inherited from OpalListenerIP
 OpalListenerIP (OpalEndPoint &endpoint, PIPSocket::Address binding=PIPSocket::GetDefaultIpAny(), WORD port=0, PBoolean exclusive=true)
 
 OpalListenerIP (OpalEndPoint &endpoint, const OpalTransportAddress &binding, OpalTransportAddress::BindOptions option)
 
virtual OpalTransportAddress GetLocalAddress (const OpalTransportAddress &remoteAddress=OpalTransportAddress(), const OpalTransportAddress &defaultAddress=OpalTransportAddress()) const
 
WORD GetListenerPort () const
 
- Public Member Functions inherited from OpalListener
 OpalListener (OpalEndPoint &endpoint)
 
void PrintOn (ostream &strm) const
 
void CloseWait ()
 
void CleanUpOnTermination ()
 

Protected Member Functions

virtual const PCaselessString & GetProtoPrefix () const
 
virtual OpalTransportOnAccept (PTCPSocket *socket)
 
- Protected Member Functions inherited from OpalListenerIP
bool CanCreateTransport (const OpalTransportAddress &localAddress, const OpalTransportAddress &remoteAddress) const
 
- Protected Member Functions inherited from OpalListener
void ListenForConnections ()
 
void TransportThreadMain (OpalTransportPtr transport)
 

Protected Attributes

PTCPSocket m_listener
 
- Protected Attributes inherited from OpalListenerIP
PIPSocketAddressAndPort m_binding
 
bool m_exclusiveListener
 
- Protected Attributes inherited from OpalListener
OpalEndPointm_endpoint
 
PThread * m_thread
 
AcceptHandler m_acceptHandler
 
ThreadMode m_threadMode
 

Constructor & Destructor Documentation

OpalListenerTCP::OpalListenerTCP ( OpalEndPoint endpoint,
PIPSocket::Address  binding = PIPSocket::GetDefaultIpAny(),
WORD  port = 0,
PBoolean  exclusive = true 
)

Create a new listener.

Parameters
endpointEndpoint listener is used for
bindingLocal interface to listen on
portTCP port to listen for connections
exclusiveExclusive listening mode, no other process can accept on the port
OpalListenerTCP::OpalListenerTCP ( OpalEndPoint endpoint,
const OpalTransportAddress binding,
OpalTransportAddress::BindOptions  option 
)
Parameters
endpointEndpoint listener is used for
bindingLocal interface to listen on
optionOPtions for binding
OpalListenerTCP::~OpalListenerTCP ( )

Destroy the listener thread.

Member Function Documentation

virtual OpalTransport* OpalListenerTCP::Accept ( const PTimeInterval &  timeout)
virtual

Accept a new incoming transport.

Parameters
timeoutTime to wait for incoming connection

Implements OpalListener.

virtual void OpalListenerTCP::Close ( )
virtual

Stop the listener thread and no longer accept incoming connections.

Implements OpalListener.

virtual OpalTransport* OpalListenerTCP::CreateTransport ( const OpalTransportAddress localAddress,
const OpalTransportAddress remoteAddress 
) const
virtual

Create a transport compatible with this listener.

Implements OpalListener.

virtual const PCaselessString& OpalListenerTCP::GetProtoPrefix ( ) const
protectedvirtual

Implements OpalListener.

virtual bool OpalListenerTCP::IsOpen ( ) const
virtual

Indicate if the listener is open.

Implements OpalListener.

virtual OpalTransport* OpalListenerTCP::OnAccept ( PTCPSocket *  socket)
protectedvirtual
virtual bool OpalListenerTCP::Open ( const AcceptHandler acceptHandler,
ThreadMode  mode = SpawnNewThreadMode 
)
virtual

Open the listener. Listen for an incoming connection and create a OpalTransport of the appropriate subclass.

If notifier function acceptHandler is non-NULL a thread is spawned to listen for incoming connections. The acceptHandler is called when a new connection is created. The INT parameter to the acceptHandler is a pointer to the new OpalTransport instance created by the listener.

If singleThread is false the acceptHandler function is called in the context of a new thread and the continues to listen for more connections. If true, then the acceptHandler function is called from within the listener threads context and no more connections are created. That is only a single connection is ever created by this listener.

If acceptHandler is NULL, then no thread is started and it is assumed that the caller is responsible for calling Accept() and waiting for the new connection.

Parameters
acceptHandlerHandler function for new connections
modeHow handler function is called thread wise

Reimplemented from OpalListener.

Field Documentation

PTCPSocket OpalListenerTCP::m_listener
protected

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