|
PionNetworkLibrary
|
#include <server.hpp>


Public Member Functions | |
| virtual | ~server () |
| default destructor More... | |
| void | start (void) |
| starts listening for new connections More... | |
| void | stop (bool wait_until_finished=false) |
| void | join (void) |
| the calling thread will sleep until the server has stopped listening for connections More... | |
| void | set_ssl_key_file (const std::string &pem_key_file) |
| std::size_t | get_connections (void) const |
| returns the number of active tcp connections More... | |
| unsigned int | get_port (void) const |
| returns tcp port number that the server listens for connections on More... | |
| void | set_port (unsigned int p) |
| sets tcp port number that the server listens for connections on More... | |
| boost::asio::ip::address | get_address (void) const |
| returns IP address that the server listens for connections on More... | |
| void | set_address (const boost::asio::ip::address &addr) |
| sets IP address that the server listens for connections on More... | |
| const boost::asio::ip::tcp::endpoint & | get_endpoint (void) const |
| returns tcp endpoint that the server listens for connections on More... | |
| void | set_endpoint (const boost::asio::ip::tcp::endpoint &ep) |
| sets tcp endpoint that the server listens for connections on More... | |
| bool | get_ssl_flag (void) const |
| returns true if the server uses SSL to encrypt connections More... | |
| void | set_ssl_flag (bool b=true) |
| sets value of SSL flag (true if the server uses SSL to encrypt connections) More... | |
| connection::ssl_context_type & | get_ssl_context_type (void) |
| returns the SSL context for configuration More... | |
| bool | is_listening (void) const |
| returns true if the server is listening for connections More... | |
| void | set_logger (logger log_ptr) |
| sets the logger to be used More... | |
| logger | get_logger (void) |
| returns the logger currently in use More... | |
| boost::asio::ip::tcp::acceptor & | get_acceptor (void) |
| returns mutable reference to the TCP connection acceptor More... | |
| const boost::asio::ip::tcp::acceptor & | get_acceptor (void) const |
| returns const reference to the TCP connection acceptor More... | |
Protected Member Functions | |
| server (const unsigned int tcp_port) | |
| server (const boost::asio::ip::tcp::endpoint &endpoint) | |
| server (scheduler &sched, const unsigned int tcp_port=0) | |
| server (scheduler &sched, const boost::asio::ip::tcp::endpoint &endpoint) | |
| virtual void | handle_connection (const tcp::connection_ptr &tcp_conn) |
| virtual void | before_starting (void) |
| called before the TCP server starts listening for new connections More... | |
| virtual void | after_stopping (void) |
| called after the TCP server has stopped listing for new connections More... | |
| boost::asio::io_service & | get_io_service (void) |
| returns an async I/O service used to schedule work More... | |
Protected Attributes | |
| logger | m_logger |
| primary logging interface used by this class More... | |
tcp::server: a multi-threaded, asynchronous TCP server
|
inlinevirtual |
default destructor
Reimplemented in pion::http::server.
|
explicitprotected |
protected constructor so that only derived objects may be created
| tcp_port | port number used to listen for new connections (IPv4) |
|
explicitprotected |
protected constructor so that only derived objects may be created
| endpoint | TCP endpoint used to listen for new connections (see ASIO docs) |
|
explicitprotected |
protected constructor so that only derived objects may be created
| sched | the scheduler that will be used to manage worker threads |
| tcp_port | port number used to listen for new connections (IPv4) |
|
protected |
protected constructor so that only derived objects may be created
| sched | the scheduler that will be used to manage worker threads |
| endpoint | TCP endpoint used to listen for new connections (see ASIO docs) |
|
inlineprotectedvirtual |
called after the TCP server has stopped listing for new connections
Reimplemented in pion::http::plugin_server.
Referenced by stop().
|
inlineprotectedvirtual |
called before the TCP server starts listening for new connections
Reimplemented in pion::http::plugin_server.
Referenced by start().
|
inline |
returns mutable reference to the TCP connection acceptor
|
inline |
returns const reference to the TCP connection acceptor
|
inline |
returns IP address that the server listens for connections on
| std::size_t pion::tcp::server::get_connections | ( | void | ) | const |
returns the number of active tcp connections
|
inline |
returns tcp endpoint that the server listens for connections on
|
inlineprotected |
returns an async I/O service used to schedule work
|
inline |
returns the logger currently in use
|
inline |
returns tcp port number that the server listens for connections on
Referenced by pion::http::server::handle_request(), start(), and stop().
|
inline |
returns the SSL context for configuration
|
inline |
returns true if the server uses SSL to encrypt connections
|
inlineprotectedvirtual |
handles a new TCP connection; derived classes SHOULD override this since the default behavior does nothing
| tcp_conn | the new TCP connection to handle |
Reimplemented in pion::http::server.
References pion::tcp::connection::LIFECYCLE_CLOSE.
|
inline |
returns true if the server is listening for connections
| void pion::tcp::server::join | ( | void | ) |
the calling thread will sleep until the server has stopped listening for connections
|
inline |
sets IP address that the server listens for connections on
|
inline |
sets tcp endpoint that the server listens for connections on
|
inline |
sets the logger to be used
|
inline |
sets tcp port number that the server listens for connections on
|
inline |
sets value of SSL flag (true if the server uses SSL to encrypt connections)
Referenced by set_ssl_key_file().
| void pion::tcp::server::set_ssl_key_file | ( | const std::string & | pem_key_file | ) |
configures server for SSL using a PEM-encoded RSA private key file
| pem_key_file | name of the file containing a PEM-encoded private key |
References set_ssl_flag().
| void pion::tcp::server::start | ( | void | ) |
starts listening for new connections
References pion::scheduler::add_active_user(), before_starting(), get_port(), m_logger, PION_LOG_ERROR, and PION_LOG_INFO.
| void pion::tcp::server::stop | ( | bool | wait_until_finished = false | ) |
stops listening for new connections
| wait_until_finished | if true, blocks until all pending connections have closed |
References after_stopping(), pion::tcp::connection::close(), get_port(), m_logger, PION_LOG_INFO, pion::scheduler::remove_active_user(), and pion::scheduler::sleep().
|
protected |
primary logging interface used by this class
Referenced by pion::http::server::add_redirect(), pion::http::server::add_resource(), pion::http::plugin_server::add_service(), pion::http::server::handle_request(), pion::http::plugin_server::load_service(), pion::http::plugin_server::load_service_config(), pion::http::server::remove_resource(), pion::http::plugin_server::set_service_option(), start(), and stop().