#include <pStatServer.h>
Inheritance diagram for PStatServer:
Public Member Functions | |
PStatServer () | |
~PStatServer () | |
bool | listen (int port=-1) |
Establishes a port number that the manager will listen on for TCP connections. | |
void | poll () |
Checks for any network activity and handles it, if appropriate, and then returns. | |
void | main_loop (bool *interrupt_flag=NULL) |
An alternative to repeatedly calling poll(), this function yields control of the program to the PStatServer. | |
virtual PStatMonitor * | make_monitor ()=0 |
void | add_reader (Connection *connection, PStatReader *reader) |
Adds the newly-created PStatReader to the list of currently active readers. | |
void | remove_reader (Connection *connection, PStatReader *reader) |
Removes the indicated reader. | |
int | get_udp_port () |
Returns a new port number that will probably be free to use as a UDP port. | |
void | release_udp_port (int port) |
Indicates that the given UDP port is once again free for use. | |
virtual bool | is_thread_safe () |
This should be redefined to return true in derived classes that want to deal with multithreaded readers and such. | |
PointerTo< Connection > | open_UDP_connection (int port=0) |
PointerTo< Connection > | open_TCP_server_rendezvous (int port, int backlog) |
PointerTo< Connection > | open_TCP_client_connection (const NetAddress &address, int timeout_ms) |
PointerTo< Connection > | open_TCP_client_connection (const string &hostname, int port, int timeout_ms) |
bool | close_connection (const PointerTo< Connection > &connection) |
void | new_connection (const PointerTo< Connection > &connection) |
virtual void | connection_reset (const PointerTo< Connection > &connection)=0 |
void | add_reader (ConnectionReader *reader) |
void | remove_reader (ConnectionReader *reader) |
void | add_writer (ConnectionWriter *writer) |
void | remove_writer (ConnectionWriter *writer) |
Static Public Member Functions | |
string | get_host_name () |
Public Attributes | |
pset< PointerTo< Connection > > | Connections |
pset< ConnectionWriter * > | Writers |
Connections | _connections |
Writers | _writers |
PRLock * | _set_mutex |
Private Types | |
typedef pmap< PT(Connection), PStatReader * | Readers ) |
typedef pvector< PStatReader * > | LostReaders |
typedef pdeque< int > | Ports |
Private Member Functions | |
virtual void | connection_reset (const PT(Connection)&connection) |
Private Attributes | |
PStatListener * | _listener |
Readers | _readers |
LostReaders | _lost_readers |
LostReaders | _removed_readers |
Ports | _available_udp_ports |
int | _next_udp_port |
Friends | |
class | ConnectionReader |
class | ConnectionWriter |
class | ConnectionListener |
class | Connection |
This class gets the ball rolling; to use this package, you need to derive from this and define make_monitor() to allocate and return a PStatMonitor of the suitable type.
Then create just one PStatServer object and call listen() with the port(s) you would like to listen on. It will automatically create PStatMonitors as connections are established and mark the connections closed as they are lost.
Definition at line 63 of file pStatServer.h.
|
Definition at line 89 of file pStatServer.h. |
|
Definition at line 93 of file pStatServer.h. |
|
Reimplemented from ConnectionManager. Definition at line 87 of file pStatServer.h. |
|
Definition at line 35 of file pStatServer.cxx. References _listener. |
|
Definition at line 48 of file pStatServer.cxx. References _listener, _next_udp_port, ConnectionListener::add_connection(), ConnectionManager::open_TCP_server_rendezvous(), pstats_port, and PT. |
|
Adds the newly-created PStatReader to the list of currently active readers.
Definition at line 202 of file pStatServer.cxx. References _available_udp_ports. Referenced by PStatListener::PStatListener(). |
|
|
|
Returns a new port number that will probably be free to use as a UDP port. The caller should be prepared to accept the possibility that it will be already in use by another process, however. Definition at line 241 of file pStatServer.cxx. References _lost_readers, _readers, and reader(). Referenced by PStatReader::close(). |
|
This should be redefined to return true in derived classes that want to deal with multithreaded readers and such. If this returns true, the manager will create the listener in its own thread, and thus the PStatReader constructors at least will run in a different thread. This is not related to the question of whether the reader can handle multiple different PStatThreadDatas; it's strictly a question of whether the readers themselves can run in a separate thread. Definition at line 294 of file pStatServer.cxx. |
|
Establishes a port number that the manager will listen on for TCP connections. This may be called more than once to listen simulataneously on multiple connections, as if that were at all useful. The default parameter, -1, indicates the use of whatever port number has been indicated in the Config file. This function returns true if the port was successfully opened, or false if it could not open the port. Definition at line 84 of file pStatServer.cxx. References _listener, _lost_readers, _readers, _removed_readers, ConnectionListener::poll(), and reader(). Referenced by TextStats::make_monitor(). |
|
An alternative to repeatedly calling poll(), this function yields control of the program to the PStatServer. It does not return until the program is done. If interrupt_flag is non-NULL, it is the address of a bool variable that is initially false, and may be asynchronously set true to indicate the loop should terminate. Definition at line 181 of file pStatServer.cxx. References _available_udp_ports, and _next_udp_port. |
|
Implemented in GtkStatsServer, and TextStats. Referenced by PStatListener::PStatListener(). |
|
Checks for any network activity and handles it, if appropriate, and then returns. This must be called periodically unless is_thread_safe() is redefined to return true on this class and also on all PStatMonitors in use. Alternatively, a program may call main_loop() and yield control of the program entirely to the PStatServer. Definition at line 132 of file pStatServer.cxx. References NULL. |
|
Indicates that the given UDP port is once again free for use.
Definition at line 261 of file pStatServer.cxx. |
|
Removes the indicated reader.
Definition at line 215 of file pStatServer.cxx. Referenced by PStatReader::~PStatReader(). |
|
Definition at line 94 of file pStatServer.h. Referenced by add_reader(), and main_loop(). |
|
Definition at line 85 of file pStatServer.h. Referenced by listen(), PStatServer(), and ~PStatServer(). |
|
Definition at line 90 of file pStatServer.h. Referenced by get_udp_port(), and listen(). |
|
Definition at line 95 of file pStatServer.h. Referenced by main_loop(), and ~PStatServer(). |
|
Reimplemented from ConnectionManager. Definition at line 88 of file pStatServer.h. Referenced by get_udp_port(), and listen(). |
|
Definition at line 91 of file pStatServer.h. Referenced by listen(). |