Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

ConnectionListener Class Reference

This is a special kind of ConnectionReader that waits for activity on a rendezvous port and accepts a TCP connection (instead of attempting to read a datagram from the rendezvous port). More...

#include <connectionListener.h>

Inheritance diagram for ConnectionListener:

ConnectionReader QueuedConnectionListener List of all members.

Public Member Functions

 ConnectionListener (ConnectionManager *manager, int num_threads)
bool add_connection (const PointerTo< Connection > &connection)
 Adds a new socket to the list of sockets the ConnectionReader will monitor.

bool remove_connection (const PointerTo< Connection > &connection)
 Removes a socket from the list of sockets being monitored.

bool is_connection_ok (const PointerTo< Connection > &connection)
 Returns true if the indicated connection has been added to the ConnectionReader and is being monitored properly, false if it is not known, or if there was some error condition detected on the connection.

void poll ()
 Explicitly polls the available sockets to see if any of them have any noise.

ConnectionManagerget_manager () const
 Returns a pointer to the ConnectionManager object that serves this ConnectionReader.

bool is_polling () const
 Returns true if the reader is a polling reader, i.e.

int get_num_threads () const
 Returns the number of threads the ConnectionReader has been created with.

void set_raw_mode (bool mode)
 Sets the ConnectionReader into raw mode (or turns off raw mode).

bool get_raw_mode () const
 Returns the current setting of the raw mode flag.


Protected Member Functions

virtual void receive_datagram (const NetDatagram &datagram)
 This function must be declared because it is pure virtual in the base class, but it isn't used in this class and doesn't do anything.

virtual void connection_opened (const PointerTo< Connection > &rendezvous, const NetAddress &address, const PointerTo< Connection > &new_connection)=0
virtual void process_incoming_data (SocketInfo *sinfo)
 This is the function that is called when activity is detected on a rendezvous port.

void shutdown ()
 Terminates all threads cleanly.

void clear_manager ()
 This should normally only be called when the associated ConnectionManager destructs.

void finish_socket (SocketInfo *sinfo)
 To be called when a socket has been fully read and is ready for polling for additional data.

virtual void process_incoming_udp_data (SocketInfo *sinfo)
virtual void process_incoming_tcp_data (SocketInfo *sinfo)
virtual void process_raw_incoming_udp_data (SocketInfo *sinfo)
virtual void process_raw_incoming_tcp_data (SocketInfo *sinfo)

Protected Attributes

ConnectionManager_manager

Detailed Description

This is a special kind of ConnectionReader that waits for activity on a rendezvous port and accepts a TCP connection (instead of attempting to read a datagram from the rendezvous port).

It is itself an abstract class, as it doesn't define what to do with the established connection. See QueuedConnectionListener.

Definition at line 52 of file connectionListener.h.


Constructor & Destructor Documentation

ConnectionListener::ConnectionListener ConnectionManager manager,
int  num_threads
 

Definition at line 37 of file connectionListener.cxx.


Member Function Documentation

bool ConnectionReader::add_connection const PointerTo< Connection > &  connection  )  [inherited]
 

Adds a new socket to the list of sockets the ConnectionReader will monitor.

A datagram that comes in on any of the monitored sockets will be reported. In the case of a ConnectionListener, this adds a new rendezvous socket; any activity on any of the monitored sockets will cause a connection to be accepted.

The return value is true if the connection was added, false if it was already there.

add_connection() is thread-safe, and may be called at will by any thread.

Definition at line 210 of file connectionReader.cxx.

References ConnectionReader::_reexamine_sockets, ConnectionReader::_removed_sockets, ConnectionReader::_sockets, and ConnectionReader::_sockets_mutex.

void ConnectionReader::clear_manager  )  [protected, inherited]
 

This should normally only be called when the associated ConnectionManager destructs.

It resets the ConnectionManager pointer to NULL so we don't have a floating pointer. This makes the ConnectionReader invalid; presumably it also will be destructed momentarily.

Definition at line 487 of file connectionReader.cxx.

virtual void ConnectionListener::connection_opened const PointerTo< Connection > &  rendezvous,
const NetAddress address,
const PointerTo< Connection > &  new_connection
[protected, pure virtual]
 

Implemented in QueuedConnectionListener.

void ConnectionReader::finish_socket SocketInfo *  sinfo  )  [protected, inherited]
 

To be called when a socket has been fully read and is ready for polling for additional data.

Definition at line 502 of file connectionReader.cxx.

ConnectionManager * ConnectionReader::get_manager  )  const [inherited]
 

Returns a pointer to the ConnectionManager object that serves this ConnectionReader.

Definition at line 364 of file connectionReader.cxx.

References ConnectionReader::_threads.

int ConnectionReader::get_num_threads  )  const [inherited]
 

Returns the number of threads the ConnectionReader has been created with.

Definition at line 394 of file connectionReader.cxx.

bool ConnectionReader::get_raw_mode  )  const [inherited]
 

Returns the current setting of the raw mode flag.

See set_raw_mode().

Definition at line 428 of file connectionReader.cxx.

bool ConnectionReader::is_connection_ok const PointerTo< Connection > &  connection  )  [inherited]
 

Returns true if the indicated connection has been added to the ConnectionReader and is being monitored properly, false if it is not known, or if there was some error condition detected on the connection.

(If there was an error condition, normally the ConnectionManager would have been informed and closed the connection.)

Definition at line 296 of file connectionReader.cxx.

References ConnectionReader::_manager.

bool ConnectionReader::is_polling  )  const [inherited]
 

Returns true if the reader is a polling reader, i.e.

it has no threads.

Definition at line 379 of file connectionReader.cxx.

void ConnectionReader::poll  )  [inherited]
 

Explicitly polls the available sockets to see if any of them have any noise.

This function does nothing unless this is a polling-type ConnectionReader, i.e. it was created with zero threads (and is_polling() will return true).

It is not necessary to call this explicitly for a QueuedConnectionReader.

Definition at line 342 of file connectionReader.cxx.

References ConnectionReader::_raw_mode.

Referenced by QueuedConnectionListener::~QueuedConnectionListener().

void ConnectionListener::process_incoming_data SocketInfo *  sinfo  )  [protected, virtual]
 

This is the function that is called when activity is detected on a rendezvous port.

In this case, it performs the accept().

Reimplemented from ConnectionReader.

Definition at line 73 of file connectionListener.cxx.

References ConnectionReader::_manager, and NULL.

void ConnectionReader::process_incoming_tcp_data SocketInfo *  sinfo  )  [protected, virtual, inherited]
 

Definition at line 640 of file connectionReader.cxx.

void ConnectionReader::process_incoming_udp_data SocketInfo *  sinfo  )  [protected, virtual, inherited]
 

Definition at line 567 of file connectionReader.cxx.

void ConnectionReader::process_raw_incoming_tcp_data SocketInfo *  sinfo  )  [protected, virtual, inherited]
 

Definition at line 839 of file connectionReader.cxx.

References ConnectionReader::_next_index, ConnectionReader::_num_results, ConnectionReader::_poll, ConnectionReader::_polled_sockets, ConnectionReader::_reexamine_sockets, ConnectionReader::_shutdown, and NULL.

void ConnectionReader::process_raw_incoming_udp_data SocketInfo *  sinfo  )  [protected, virtual, inherited]
 

Definition at line 785 of file connectionReader.cxx.

void ConnectionListener::receive_datagram const NetDatagram datagram  )  [protected, virtual]
 

This function must be declared because it is pure virtual in the base class, but it isn't used in this class and doesn't do anything.

Implements ConnectionReader.

Definition at line 55 of file connectionListener.cxx.

References NetAddress::get_ip_string(), NULL, and pprerror().

bool ConnectionReader::remove_connection const PointerTo< Connection > &  connection  )  [inherited]
 

Removes a socket from the list of sockets being monitored.

Returns true if the socket was correctly removed, false if it was not on the list in the first place.

remove_connection() is thread-safe, and may be called at will by any thread.

Definition at line 253 of file connectionReader.cxx.

void ConnectionReader::set_raw_mode bool  mode  )  [inherited]
 

Sets the ConnectionReader into raw mode (or turns off raw mode).

In raw mode, datagram headers are not expected; instead, all the data available on the pipe is treated as a single datagram.

Definition at line 413 of file connectionReader.cxx.

Referenced by HTTPClient::HTTPClient().

void ConnectionReader::shutdown  )  [protected, inherited]
 

Terminates all threads cleanly.

Normally this is only called by the destructor.

Definition at line 443 of file connectionReader.cxx.

Referenced by QueuedConnectionListener::QueuedConnectionListener().


Member Data Documentation

ConnectionManager* ConnectionReader::_manager [protected, inherited]
 

Definition at line 146 of file connectionReader.h.

Referenced by ConnectionReader::SocketInfo::get_socket(), ConnectionReader::is_connection_ok(), ConnectionReader::process_incoming_data(), and process_incoming_data().


The documentation for this class was generated from the following files:
Generated on Fri May 2 00:48:48 2003 for Panda by doxygen1.3