Listener Class Reference
[Listener implementation classes]

Abstract class for any type of Listener. More...

#include <listener.h>

Inheritance diagram for Listener:

Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual ~Listener ()
 As with Connector, any subclass of Listener that needs its disconnect() method called must call it from their own destructor.
virtual ConnectorP listen_for_incoming ()=0
 Wait for and accept an incoming connection.
virtual void disconnect ()=0
 Disconnect.
virtual std::string get_id (void) const =0
 Instance identification string (abstract virtual).
virtual std::string class_name (void) const =0


Detailed Description

Abstract class for any type of Listener.

Objects of this class (really, of a sublass of this class) contain the information necessary listen on a particular connection, such as a Unix-domain socket, a TCP socket, or a device.

To use a Listener, first instantiate one of the appropriate subclass for the type of connection you'd like to listen for, and pass the constructor the necessary information about that connection. Then, call the listen_for_incoming method, which will block waiting for incoming connections. When a connection comes in, listen_for_incoming will return a Connector that is connected and ready to read and write on the new connection. You'll probably want to start a thread to handle the I/O over that Connector, and then call listen_for_incoming again to wait for another connection.

When you are done listening for incoming connections, call disconnect(), which will terminate any listen_for_incoming calls that are outstanding (which will, in turn, return NULL), and close the underlying connection, effectively ending the listening. The Listener object will then be unuseful for further work, and should be deleted. XXX - Can we actually interrupt the thread that's blocked listening on the socket?

XXX - If we're going to allow disconnect() to be called and interrupt listen_for_incoming(), there needs to be an extra thread somewhere. Do either Listener::Listener() or Listener::listen_for_incoming() create a thread to do something? If not, there's no way to have someone call disconnect while the thread that instantiated the Listener is blocked in Listener::listen_for_incoming()...

Definition at line 84 of file listener.h.


Constructor & Destructor Documentation

virtual Listener::~Listener (  )  [inline, virtual]

As with Connector, any subclass of Listener that needs its disconnect() method called must call it from their own destructor.

Definition at line 90 of file listener.h.


Member Function Documentation

virtual ConnectorP Listener::listen_for_incoming (  )  [pure virtual]

Wait for and accept an incoming connection.

Blocks, and returns a new Connector object when it accepts a new incoming connection, or NULL on failure (?). The caller should instantiate a new Connection passing this Connector object to Connection's constructor. This returned Connector will already be connected.

Implemented in SocketListener.

Referenced by accept_and_send_on_connection().

Here is the caller graph for this function:

virtual void Listener::disconnect (  )  [pure virtual]

Disconnect.

Implemented in SocketListener, and UDSListener.

Referenced by tcp_test(), and uds_test().

Here is the caller graph for this function:

virtual std::string Listener::get_id ( void   )  const [pure virtual]

Instance identification string (abstract virtual).

Implemented in SocketListener, and UDSListener.

Referenced by accept_and_send_on_connection().

Here is the caller graph for this function:

virtual std::string Listener::class_name ( void   )  const [pure virtual]

Implemented in SocketListener, and UDSListener.


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

Generated on Tue May 13 11:32:47 2008 for consmgr by  doxygen 1.5.5