# OpalListenerTCP Class Reference

`#include <transports.h>`

Inheritance diagram for OpalListenerTCP:

List of all members.

## Public Member Functions

Overrides from OpalListener
virtual PBoolean | Open (const PNotifier &acceptHandler, ThreadMode mode=SpawnNewThreadMode)
virtual PBoolean | IsOpen ()
virtual void | Close ()
virtual OpalTransport * | Accept (const PTimeInterval &timeout)
virtual OpalTransport * | CreateTransport (const OpalTransportAddress &localAddress, const OpalTransportAddress &remoteAddress) const

## Protected Member Functions

virtual const char * | GetProtoPrefix () const

## Protected Attributes

PTCPSocket | listener

## Constructor & Destructor Documentation

OpalListenerTCP::OpalListenerTCP | ( | OpalEndPoint & | endpoint,
|  | PIPSocket::Address | binding = `PIPSocket::GetDefaultIpAny()`,
|  | WORD | port = `0`,
|  | PBoolean | exclusive = `PTrue` |
| ) |  |  |

Create a new listener.

Parameters:

  endpoint | Endpoint listener is used for
  binding | Local interface to listen on
  port | TCP port to listen for connections

OpalListenerTCP::OpalListenerTCP | ( | OpalEndPoint & | endpoint,
|  | const OpalTransportAddress & | binding,
|  | OpalTransportAddress::BindOptions | option |
| ) |  |  |

Parameters:

  endpoint | Endpoint listener is used for
  binding | Local interface to listen on
  option | OPtions for binding

OpalListenerTCP::~OpalListenerTCP | ( |  | ) |

Destroy the listener thread.

OpalListenerTCP::OpalListenerTCP | ( | OpalEndPoint & | endpoint,
|  | PIPSocket::Address | binding = `PIPSocket::GetDefaultIpAny()`,
|  | WORD | port = `0`,
|  | PBoolean | exclusive = `PTrue` |
| ) |  |  |

Create a new listener.

Parameters:

  endpoint | Endpoint listener is used for
  binding | Local interface to listen on
  port | TCP port to listen for connections

OpalListenerTCP::OpalListenerTCP | ( | OpalEndPoint & | endpoint,
|  | const OpalTransportAddress & | binding,
|  | OpalTransportAddress::BindOptions | option |
| ) |  |  |

Parameters:

  endpoint | Endpoint listener is used for
  binding | Local interface to listen on
  option | OPtions for binding

OpalListenerTCP::~OpalListenerTCP | ( |  | ) |

Destroy the listener thread.

## Member Function Documentation

virtual PBoolean OpalListenerTCP::Open | ( | const PNotifier & | 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 PFalse the acceptHandler function is called in the context of a new thread and the continues to listen for more connections. If PTrue, 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:

  acceptHandler | Handler function for new connections
  mode | How handler function is called thread wise

Implements OpalListener.

virtual PBoolean OpalListenerTCP::IsOpen | ( |  | ) | `[virtual]`

Indicate if the listener is open.

Implements OpalListener.

virtual void OpalListenerTCP::Close | ( |  | ) | `[virtual]`

Stop the listener thread and no longer accept incoming connections.

Implements OpalListener.

virtual OpalTransport* OpalListenerTCP::Accept | ( | const PTimeInterval & | timeout | ) | `[virtual]`

Accept a new incoming transport.

Parameters:

  timeout | Time to wait for incoming connection

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 char* OpalListenerTCP::GetProtoPrefix | ( |  | ) | const`[protected, virtual]`

Implements OpalListenerIP.

## Member Data Documentation

PTCPSocket OpalListenerTCP::listener `[protected]`

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

- transports.h