Wire Sysio Wire Sysion 1.0.0
|
Asio based endpoint transport component. More...
#include <endpoint.hpp>
Public Types | |
typedef endpoint< config > | type |
Type of this endpoint transport component. | |
typedef config::concurrency_type | concurrency_type |
Type of the concurrency policy. | |
typedef config::socket_type | socket_type |
Type of the socket policy. | |
typedef config::elog_type | elog_type |
Type of the error logging policy. | |
typedef config::alog_type | alog_type |
Type of the access logging policy. | |
typedef socket_type::socket_con_type | socket_con_type |
Type of the socket connection component. | |
typedef socket_con_type::ptr | socket_con_ptr |
Type of a shared pointer to the socket connection component. | |
typedef asio::connection< config > | transport_con_type |
typedef transport_con_type::ptr | transport_con_ptr |
typedef lib::asio::io_service * | io_service_ptr |
Type of a pointer to the ASIO io_service being used. | |
typedef lib::shared_ptr< lib::asio::ip::tcp::acceptor > | acceptor_ptr |
Type of a shared pointer to the acceptor being used. | |
typedef lib::shared_ptr< lib::asio::ip::tcp::resolver > | resolver_ptr |
Type of a shared pointer to the resolver being used. | |
typedef lib::shared_ptr< lib::asio::steady_timer > | timer_ptr |
Type of timer handle. | |
typedef lib::shared_ptr< lib::asio::io_service::work > | work_ptr |
Type of a shared pointer to an io_service work object. | |
Public Member Functions | |
endpoint () | |
~endpoint () | |
bool | is_secure () const |
Return whether or not the endpoint produces secure connections. | |
void | init_asio (io_service_ptr ptr, lib::error_code &ec) |
initialize asio transport with external io_service (exception free) | |
void | init_asio (io_service_ptr ptr) |
initialize asio transport with external io_service | |
void | init_asio (lib::error_code &ec) |
Initialize asio transport with internal io_service (exception free) | |
void | init_asio () |
Initialize asio transport with internal io_service. | |
void | set_tcp_pre_init_handler (tcp_init_handler h) |
Sets the tcp pre init handler. | |
void | set_tcp_init_handler (tcp_init_handler h) |
Sets the tcp pre init handler (deprecated) | |
void | set_tcp_post_init_handler (tcp_init_handler h) |
Sets the tcp post init handler. | |
void | set_listen_backlog (int backlog) |
Sets the maximum length of the queue of pending connections. | |
void | set_reuse_addr (bool value) |
Sets whether to use the SO_REUSEADDR flag when opening listening sockets. | |
lib::asio::io_service & | get_io_service () |
Retrieve a reference to the endpoint's io_service. | |
lib::asio::ip::tcp::endpoint | get_local_endpoint (lib::asio::error_code &ec) |
Get local TCP endpoint. | |
void | listen (lib::asio::ip::tcp::endpoint const &ep, lib::error_code &ec) |
Set up endpoint for listening manually (exception free) | |
void | listen (lib::asio::ip::tcp::endpoint const &ep) |
Set up endpoint for listening manually. | |
template<typename InternetProtocol > | |
void | listen (InternetProtocol const &internet_protocol, uint16_t port, lib::error_code &ec) |
Set up endpoint for listening with protocol and port (exception free) | |
template<typename InternetProtocol > | |
void | listen (InternetProtocol const &internet_protocol, uint16_t port) |
Set up endpoint for listening with protocol and port. | |
void | listen (uint16_t port, lib::error_code &ec) |
Set up endpoint for listening on a port (exception free) | |
void | listen (uint16_t port) |
Set up endpoint for listening on a port. | |
void | listen (std::string const &host, std::string const &service, lib::error_code &ec) |
Set up endpoint for listening on a host and service (exception free) | |
void | listen (std::string const &host, std::string const &service) |
Set up endpoint for listening on a host and service. | |
void | stop_listening (lib::error_code &ec) |
Stop listening (exception free) | |
void | stop_listening () |
Stop listening. | |
bool | is_listening () const |
Check if the endpoint is listening. | |
std::size_t | run () |
wraps the run method of the internal io_service object | |
std::size_t | run_one () |
wraps the run_one method of the internal io_service object | |
void | stop () |
wraps the stop method of the internal io_service object | |
std::size_t | poll () |
wraps the poll method of the internal io_service object | |
std::size_t | poll_one () |
wraps the poll_one method of the internal io_service object | |
void | reset () |
wraps the reset method of the internal io_service object | |
bool | stopped () const |
wraps the stopped method of the internal io_service object | |
void | start_perpetual () |
Marks the endpoint as perpetual, stopping it from exiting when empty. | |
void | stop_perpetual () |
Clears the endpoint's perpetual flag, allowing it to exit when empty. | |
timer_ptr | set_timer (long duration, timer_handler callback) |
Call back a function after a period of time. | |
void | handle_timer (timer_ptr, timer_handler callback, lib::asio::error_code const &ec) |
Timer handler. | |
void | async_accept (transport_con_ptr tcon, accept_handler callback, lib::error_code &ec) |
Accept the next connection attempt and assign it to con (exception free) | |
void | async_accept (transport_con_ptr tcon, accept_handler callback) |
Accept the next connection attempt and assign it to con. | |
Protected Member Functions | |
void | init_logging (alog_type *a, elog_type *e) |
Initialize logging. | |
void | handle_accept (accept_handler callback, lib::asio::error_code const &asio_ec) |
void | async_connect (transport_con_ptr tcon, uri_ptr u, connect_handler cb) |
Initiate a new connection. | |
void | handle_resolve_timeout (timer_ptr, connect_handler callback, lib::error_code const &ec) |
DNS resolution timeout handler. | |
void | handle_resolve (transport_con_ptr tcon, timer_ptr dns_timer, connect_handler callback, lib::asio::error_code const &ec, lib::asio::ip::tcp::resolver::iterator iterator) |
void | handle_connect_timeout (transport_con_ptr tcon, timer_ptr, connect_handler callback, lib::error_code const &ec) |
Asio connect timeout handler. | |
void | handle_connect (transport_con_ptr tcon, timer_ptr con_timer, connect_handler callback, lib::asio::error_code const &ec) |
lib::error_code | init (transport_con_ptr tcon) |
Initialize a connection. | |
transport::asio::endpoint implements an endpoint transport component using Asio.
Definition at line 53 of file endpoint.hpp.
lib::shared_ptr<lib::asio::ip::tcp::acceptor> websocketpp::transport::asio::endpoint< config >::acceptor_ptr |
Definition at line 82 of file endpoint.hpp.
config::alog_type websocketpp::transport::asio::endpoint< config >::alog_type |
Definition at line 65 of file endpoint.hpp.
config::concurrency_type websocketpp::transport::asio::endpoint< config >::concurrency_type |
Definition at line 59 of file endpoint.hpp.
config::elog_type websocketpp::transport::asio::endpoint< config >::elog_type |
Definition at line 63 of file endpoint.hpp.
lib::asio::io_service* websocketpp::transport::asio::endpoint< config >::io_service_ptr |
Definition at line 80 of file endpoint.hpp.
lib::shared_ptr<lib::asio::ip::tcp::resolver> websocketpp::transport::asio::endpoint< config >::resolver_ptr |
Definition at line 84 of file endpoint.hpp.
socket_con_type::ptr websocketpp::transport::asio::endpoint< config >::socket_con_ptr |
Definition at line 70 of file endpoint.hpp.
socket_type::socket_con_type websocketpp::transport::asio::endpoint< config >::socket_con_type |
Definition at line 68 of file endpoint.hpp.
config::socket_type websocketpp::transport::asio::endpoint< config >::socket_type |
Definition at line 61 of file endpoint.hpp.
lib::shared_ptr<lib::asio::steady_timer> websocketpp::transport::asio::endpoint< config >::timer_ptr |
Definition at line 86 of file endpoint.hpp.
transport_con_type::ptr websocketpp::transport::asio::endpoint< config >::transport_con_ptr |
Type of a shared pointer to the connection transport component associated with this endpoint transport component
Definition at line 77 of file endpoint.hpp.
asio::connection<config> websocketpp::transport::asio::endpoint< config >::transport_con_type |
Type of the connection transport component associated with this endpoint transport component
Definition at line 74 of file endpoint.hpp.
endpoint<config> websocketpp::transport::asio::endpoint< config >::type |
Definition at line 56 of file endpoint.hpp.
lib::shared_ptr<lib::asio::io_service::work> websocketpp::transport::asio::endpoint< config >::work_ptr |
Definition at line 88 of file endpoint.hpp.
|
inlineexplicit |
Definition at line 91 of file endpoint.hpp.
|
inline |
Definition at line 101 of file endpoint.hpp.
|
inline |
tcon | The connection to accept into. |
callback | The function to call when the operation is complete. |
Definition at line 779 of file endpoint.hpp.
|
inline |
tcon | The connection to accept into. |
callback | The function to call when the operation is complete. |
ec | A status code indicating an error, if any. |
Definition at line 740 of file endpoint.hpp.
|
inlineprotected |
Definition at line 821 of file endpoint.hpp.
|
inline |
The io_service may be an internal or external one. This may be used to call methods of the io_service that are not explicitly wrapped by the endpoint.
This method is only valid after the endpoint has been initialized with init_asio
. No error will be returned if it isn't.
Definition at line 356 of file endpoint.hpp.
|
inline |
Extracts the local endpoint from the acceptor. This represents the address that WebSocket++ is listening on.
Sets a bad_descriptor error if the acceptor is not currently listening or otherwise unavailable.
ec | Set to indicate what error occurred, if any. |
Definition at line 373 of file endpoint.hpp.
|
inlineprotected |
Definition at line 800 of file endpoint.hpp.
|
inlineprotected |
Definition at line 1048 of file endpoint.hpp.
|
inlineprotected |
The timer pointer is included to ensure the timer isn't destroyed until after it has expired.
tcon | Pointer to the transport connection that is being connected |
con_timer | Pointer to the timer in question |
callback | The function to call back |
ec | A status code indicating an error, if any. |
Definition at line 1025 of file endpoint.hpp.
|
inlineprotected |
Definition at line 939 of file endpoint.hpp.
|
inlineprotected |
The timer pointer is included to ensure the timer isn't destroyed until after it has expired.
dns_timer | Pointer to the timer in question |
callback | The function to call back |
ec | A status code indicating an error, if any. |
Definition at line 916 of file endpoint.hpp.
|
inline |
The timer pointer is included to ensure the timer isn't destroyed until after it has expired.
t | Pointer to the timer in question |
callback | The function to call back |
ec | A status code indicating an error, if any. |
Definition at line 717 of file endpoint.hpp.
|
inlineprotected |
init is called by an endpoint once for each newly created connection. It's purpose is to give the transport policy the chance to perform any transport specific initialization that couldn't be done via the default constructor.
tcon | A pointer to the transport portion of the connection. |
Definition at line 1085 of file endpoint.hpp.
|
inline |
This method of initialization will allocate and use an internally managed io_service.
Definition at line 245 of file endpoint.hpp.
|
inline |
Initialize the ASIO transport policy for this endpoint using the provided io_service object. asio_init must be called exactly once on any endpoint that uses transport::asio before it can be used.
ptr | A pointer to the io_service to use for asio events |
Definition at line 208 of file endpoint.hpp.
|
inline |
Initialize the ASIO transport policy for this endpoint using the provided io_service object. asio_init must be called exactly once on any endpoint that uses transport::asio before it can be used.
ptr | A pointer to the io_service to use for asio events |
ec | Set to indicate what error occurred, if any. |
Definition at line 181 of file endpoint.hpp.
|
inline |
This method of initialization will allocate and use an internally managed io_service.
ec | Set to indicate what error occurred, if any. |
Definition at line 223 of file endpoint.hpp.
|
inlineprotected |
The loggers are located in the main endpoint class. As such, the transport doesn't have direct access to them. This method is called by the endpoint constructor to allow shared logging from the transport component. These are raw pointers to member variables of the endpoint. In particular, they cannot be used in the transport constructor as they haven't been constructed yet, and cannot be used in the transport destructor as they will have been destroyed by then.
Definition at line 795 of file endpoint.hpp.
|
inline |
Definition at line 607 of file endpoint.hpp.
|
inline |
Definition at line 168 of file endpoint.hpp.
|
inline |
Bind the internal acceptor using the given internet protocol and port. The endpoint must have been initialized by calling init_asio before listening.
Common options include:
internet_protocol | The internet protocol to use. |
port | The port to listen on. |
Definition at line 474 of file endpoint.hpp.
|
inline |
Bind the internal acceptor using the given internet protocol and port. The endpoint must have been initialized by calling init_asio before listening.
Common options include:
internet_protocol | The internet protocol to use. |
port | The port to listen on. |
ec | Set to indicate what error occurred, if any. |
Definition at line 453 of file endpoint.hpp.
|
inline |
Bind the internal acceptor using the settings specified by the endpoint e
ep | An endpoint to read settings from |
Definition at line 432 of file endpoint.hpp.
|
inline |
Bind the internal acceptor using the specified settings. The endpoint must have been initialized by calling init_asio before listening.
ep | An endpoint to read settings from |
ec | Set to indicate what error occurred, if any. |
Definition at line 390 of file endpoint.hpp.
|
inline |
Bind the internal acceptor using the given host and service. More details about what host and service can be are available in the Asio documentation for ip::basic_resolver_query::basic_resolver_query's constructors.
The endpoint must have been initialized by calling init_asio before listening.
host | A string identifying a location. May be a descriptive name or a numeric address string. |
service | A string identifying the requested service. This may be a descriptive name or a numeric string corresponding to a port number. |
ec | Set to indicate what error occurred, if any. |
Definition at line 561 of file endpoint.hpp.
|
inline |
Bind the internal acceptor using the given host and service. More details about what host and service can be are available in the Asio documentation for ip::basic_resolver_query::basic_resolver_query's constructors.
The endpoint must have been initialized by calling init_asio before listening.
host | A string identifying a location. May be a descriptive name or a numeric address string. |
service | A string identifying the requested service. This may be a descriptive name or a numeric string corresponding to a port number. |
ec | Set to indicate what error occurred, if any. |
Definition at line 528 of file endpoint.hpp.
|
inline |
Bind the internal acceptor using the given port. The IPv6 protocol with mapped IPv4 for dual stack hosts will be used. If you need IPv4 only use the overload that allows specifying the protocol explicitly.
The endpoint must have been initialized by calling init_asio before listening.
port | The port to listen on. |
ec | Set to indicate what error occurred, if any. |
Definition at line 508 of file endpoint.hpp.
|
inline |
Bind the internal acceptor using the given port. The IPv6 protocol with mapped IPv4 for dual stack hosts will be used. If you need IPv4 only use the overload that allows specifying the protocol explicitly.
The endpoint must have been initialized by calling init_asio before listening.
port | The port to listen on. |
ec | Set to indicate what error occurred, if any. |
Definition at line 492 of file endpoint.hpp.
|
inline |
Definition at line 630 of file endpoint.hpp.
|
inline |
Definition at line 635 of file endpoint.hpp.
|
inline |
Definition at line 640 of file endpoint.hpp.
|
inline |
Definition at line 612 of file endpoint.hpp.
|
inline |
Definition at line 620 of file endpoint.hpp.
|
inline |
Sets the maximum length of the queue of pending connections. Increasing this will allow WebSocket++ to queue additional incoming connections. Setting it higher may prevent failed connections at high connection rates but may cause additional latency.
For this value to take effect you may need to adjust operating system settings.
New values affect future calls to listen only.
A value of zero will use the operating system default. This is the default value.
backlog | The maximum length of the queue of pending connections |
Definition at line 323 of file endpoint.hpp.
|
inline |
Specifies whether or not to use the SO_REUSEADDR TCP socket option. What this flag does depends on your operating system. Please consult operating system documentation for more details.
New values affect future calls to listen only.
The default is false.
value | Whether or not to use the SO_REUSEADDR option |
Definition at line 341 of file endpoint.hpp.
|
inline |
The tcp pre init handler is called after the raw tcp connection has been established but before any additional wrappers (proxy connects, TLS handshakes, etc) have been performed.
h | The handler to call on tcp pre init. |
Definition at line 285 of file endpoint.hpp.
|
inline |
The tcp post init handler is called after the tcp connection has been established and all additional wrappers (proxy connects, TLS handshakes, etc have been performed. This is fired before any bytes are read or any WebSocket specific handshake logic has been performed.
h | The handler to call on tcp post init. |
Definition at line 300 of file endpoint.hpp.
|
inline |
The tcp pre init handler is called after the raw tcp connection has been established but before any additional wrappers (proxy connects, TLS handshakes, etc) have been performed.
h | The handler to call on tcp pre init. |
Definition at line 271 of file endpoint.hpp.
|
inline |
Sets a timer that calls back a function after the specified period of milliseconds. Returns a handle that can be used to cancel the timer. A cancelled timer will return the error code error::operation_aborted A timer that expired will return no error.
duration | Length of time to wait in milliseconds |
callback | The function to call back when the timer has expired |
Definition at line 689 of file endpoint.hpp.
|
inline |
Marks the endpoint as perpetual. Perpetual endpoints will not automatically exit when they run out of connections to process. To stop a perpetual endpoint call end_perpetual
.
An endpoint may be marked perpetual at any time by any thread. It must be called either before the endpoint has run out of work or before it was started
Definition at line 661 of file endpoint.hpp.
|
inline |
Definition at line 625 of file endpoint.hpp.
|
inline |
Stop listening and accepting new connections. This will not end any existing connections.
Definition at line 597 of file endpoint.hpp.
|
inline |
Stop listening and accepting new connections. This will not end any existing connections.
ec | A status code indicating an error, if any. |
Definition at line 576 of file endpoint.hpp.
|
inline |
Clears the endpoint's perpetual flag. This will cause the endpoint's run method to exit normally when it runs out of connections. If there are currently active connections it will not end until they are complete.
Definition at line 673 of file endpoint.hpp.
|
inline |
Definition at line 645 of file endpoint.hpp.