Loading...
Searching...
No Matches
websocketpp::transport::asio::endpoint< config > Class Template Reference

Asio based endpoint transport component. More...

`#include <endpoint.hpp>`

Inheritance diagram for websocketpp::transport::asio::endpoint< config >:

## 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_context * | io_context_ptr
| Type of a pointer to the ASIO io_context 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::executor_work_guard< lib::asio::io_context::executor_type > > | work_guard_ptr
| Type of a shared pointer to an io_context work object.
typedef lib::function< lib::error_code(acceptor_ptr)> | tcp_pre_bind_handler
| Type of socket pre-bind handler.

## Public Member Functions

bool | is_secure () const
| Return whether or not the endpoint produces secure connections.
void | init_asio (io_context_ptr ptr, lib::error_code &ec)
| initialize asio transport with external io_context (exception free)
void | init_asio (io_context_ptr ptr)
| initialize asio transport with external io_context
void | init_asio (lib::error_code &ec)
| Initialize asio transport with internal io_context (exception free).
void | init_asio ()
| Initialize asio transport with internal io_context.
void | set_tcp_pre_bind_handler (tcp_pre_bind_handler h)
| Sets the tcp pre bind handler.
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_context & | get_io_context ()
| Retrieve a reference to the endpoint's io_context.
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).
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).
void | listen (uint16_t port, lib::error_code &ec)
| Set up endpoint for listening on a port (exception free).
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 | stop_listening (lib::error_code &ec)
| Stop listening (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)
| Set up endpoint for listening with protocol and port.
void | listen (uint16_t port)
| Set up endpoint for listening on a port.
void | listen (std::string const &host, std::string const &service)
| Set up endpoint for listening on a host and service.
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_context object
std::size_t | run_one ()
| wraps the run_one method of the internal io_context object
void | stop ()
| wraps the stop method of the internal io_context object
std::size_t | poll ()
| wraps the poll method of the internal io_context object
std::size_t | poll_one ()
| wraps the poll_one method of the internal io_context object
void | reset ()
| wraps the restart method of the internal io_context object
bool | stopped () const
| wraps the stopped method of the internal io_context 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 (const lib::shared_ptr< alog_type > &a, const lib::shared_ptr< 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::results_type results)
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.

## Detailed Description

template<typename config>
class websocketpp::transport::asio::endpoint< config >

Asio based endpoint transport component.

transport::asio::endpoint implements an endpoint transport component using Asio.

Definition at line 54 of file endpoint.hpp.

## Member Typedef Documentation

## acceptor_ptr

template<typename config>

typedef lib::shared_ptr<lib::asio::ip::tcp::acceptor> websocketpp::transport::asio::endpoint< config >::acceptor_ptr

Type of a shared pointer to the acceptor being used.

Definition at line 83 of file endpoint.hpp.

## alog_type

template<typename config>

typedef config::alog_type websocketpp::transport::asio::endpoint< config >::alog_type

Type of the access logging policy.

Definition at line 66 of file endpoint.hpp.

## concurrency_type

template<typename config>

typedef config::concurrency_type websocketpp::transport::asio::endpoint< config >::concurrency_type

Type of the concurrency policy.

Definition at line 60 of file endpoint.hpp.

## elog_type

template<typename config>

typedef config::elog_type websocketpp::transport::asio::endpoint< config >::elog_type

Type of the error logging policy.

Definition at line 64 of file endpoint.hpp.

## io_context_ptr

template<typename config>

typedef lib::asio::io_context* websocketpp::transport::asio::endpoint< config >::io_context_ptr

Type of a pointer to the ASIO io_context being used.

Definition at line 81 of file endpoint.hpp.

## resolver_ptr

template<typename config>

typedef lib::shared_ptr<lib::asio::ip::tcp::resolver> websocketpp::transport::asio::endpoint< config >::resolver_ptr

Type of a shared pointer to the resolver being used.

Definition at line 85 of file endpoint.hpp.

## socket_con_ptr

template<typename config>

typedef socket_con_type::ptr websocketpp::transport::asio::endpoint< config >::socket_con_ptr

Type of a shared pointer to the socket connection component.

Definition at line 71 of file endpoint.hpp.

## socket_con_type

template<typename config>

typedef socket_type::socket_con_type websocketpp::transport::asio::endpoint< config >::socket_con_type

Type of the socket connection component.

Definition at line 69 of file endpoint.hpp.

## socket_type

template<typename config>

typedef config::socket_type websocketpp::transport::asio::endpoint< config >::socket_type

Type of the socket policy.

Definition at line 62 of file endpoint.hpp.

## tcp_pre_bind_handler

template<typename config>

typedef lib::function<lib::error_code(acceptor_ptr)> websocketpp::transport::asio::endpoint< config >::tcp_pre_bind_handler

Type of socket pre-bind handler.

Definition at line 92 of file endpoint.hpp.

## timer_ptr

template<typename config>

typedef lib::shared_ptr<lib::asio::steady_timer> websocketpp::transport::asio::endpoint< config >::timer_ptr

Type of timer handle.

Definition at line 87 of file endpoint.hpp.

## transport_con_ptr

template<typename config>

typedef 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 78 of file endpoint.hpp.

## transport_con_type

template<typename config>

typedef 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 75 of file endpoint.hpp.

## type

template<typename config>

typedef endpoint<config> websocketpp::transport::asio::endpoint< config >::type

Type of this endpoint transport component.

Definition at line 57 of file endpoint.hpp.

## work_guard_ptr

template<typename config>

typedef lib::shared_ptr<lib::asio::executor_work_guard<lib::asio::io_context::executor_type> > websocketpp::transport::asio::endpoint< config >::work_guard_ptr

Type of a shared pointer to an io_context work object.

Definition at line 89 of file endpoint.hpp.

## Constructor & Destructor Documentation

## endpoint()

template<typename config>

websocketpp::transport::asio::endpoint< config >::endpoint | ( |  | ) |

inline explicit

Definition at line 95 of file endpoint.hpp.

## ~endpoint()

template<typename config>

websocketpp::transport::asio::endpoint< config >::~endpoint | ( |  | ) |

inline

Definition at line 105 of file endpoint.hpp.

## Member Function Documentation

## async_accept() [1/2]

template<typename config>

void websocketpp::transport::asio::endpoint< config >::async_accept | ( | transport_con_ptr | tcon,
|  | accept_handler | callback )

inline

Accept the next connection attempt and assign it to con.

Parameters

  tcon | The connection to accept into.
  callback | The function to call when the operation is complete.

Definition at line 831 of file endpoint.hpp.

## async_accept() [2/2]

template<typename config>

void websocketpp::transport::asio::endpoint< config >::async_accept | ( | transport_con_ptr | tcon,
|  | accept_handler | callback,
|  | lib::error_code & | ec )

inline

Accept the next connection attempt and assign it to con (exception free).

Parameters

  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 791 of file endpoint.hpp.

## async_connect()

template<typename config>

void websocketpp::transport::asio::endpoint< config >::async_connect | ( | transport_con_ptr | tcon,
|  | uri_ptr | u,
|  | connect_handler | cb )

inline protected

Initiate a new connection.

Definition at line 874 of file endpoint.hpp.

## get_io_context()

template<typename config>

lib::asio::io_context & websocketpp::transport::asio::endpoint< config >::get_io_context | ( |  | ) |

inline

Retrieve a reference to the endpoint's io_context.

The io_context may be an internal or external one. This may be used to call methods of the io_context 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.

Returns
  A reference to the endpoint's io_context

Definition at line 382 of file endpoint.hpp.

## get_local_endpoint()

template<typename config>

lib::asio::ip::tcp::endpoint websocketpp::transport::asio::endpoint< config >::get_local_endpoint | ( | lib::asio::error_code & | ec | ) |

inline

Get local TCP endpoint.

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.

Since
  0.7.0

Parameters

  ec | Set to indicate what error occurred, if any.

Returns
  The local endpoint

Definition at line 399 of file endpoint.hpp.

## handle_accept()

template<typename config>

void websocketpp::transport::asio::endpoint< config >::handle_accept | ( | accept_handler | callback,
|  | lib::asio::error_code const & | asio_ec )

inline protected

Definition at line 853 of file endpoint.hpp.

## handle_connect()

template<typename config>

void websocketpp::transport::asio::endpoint< config >::handle_connect | ( | transport_con_ptr | tcon,
|  | timer_ptr | con_timer,
|  | connect_handler | callback,
|  | lib::asio::error_code const & | ec )

inline protected

Definition at line 1101 of file endpoint.hpp.

## handle_connect_timeout()

template<typename config>

void websocketpp::transport::asio::endpoint< config >::handle_connect_timeout | ( | transport_con_ptr | tcon,
|  | timer_ptr | ,
|  | connect_handler | callback,
|  | lib::error_code const & | ec )

inline protected

Asio connect timeout handler.

The timer pointer is included to ensure the timer isn't destroyed until after it has expired.

Parameters

  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 1078 of file endpoint.hpp.

## handle_resolve()

template<typename config>

void websocketpp::transport::asio::endpoint< config >::handle_resolve | ( | transport_con_ptr | tcon,
|  | timer_ptr | dns_timer,
|  | connect_handler | callback,
|  | lib::asio::error_code const & | ec,
|  | lib::asio::ip::tcp::resolver::results_type | results )

inline protected

Definition at line 992 of file endpoint.hpp.

## handle_resolve_timeout()

template<typename config>

void websocketpp::transport::asio::endpoint< config >::handle_resolve_timeout | ( | timer_ptr | ,
|  | connect_handler | callback,
|  | lib::error_code const & | ec )

inline protected

DNS resolution timeout handler.

The timer pointer is included to ensure the timer isn't destroyed until after it has expired.

Parameters

  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 969 of file endpoint.hpp.

## handle_timer()

template<typename config>

void websocketpp::transport::asio::endpoint< config >::handle_timer | ( | timer_ptr | ,
|  | timer_handler | callback,
|  | lib::asio::error_code const & | ec )

inline

Timer handler.

The timer pointer is included to ensure the timer isn't destroyed until after it has expired.

Parameters

  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 768 of file endpoint.hpp.

## init()

template<typename config>

lib::error_code websocketpp::transport::asio::endpoint< config >::init | ( | transport_con_ptr | tcon | ) |

inline protected

Initialize a connection.

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.

Parameters

  tcon | A pointer to the transport portion of the connection.

Returns
  A status code indicating the success or failure of the operation

Definition at line 1138 of file endpoint.hpp.

## init_asio() [1/4]

template<typename config>

void websocketpp::transport::asio::endpoint< config >::init_asio | ( |  | ) |

inline

Initialize asio transport with internal io_context.

This method of initialization will allocate and use an internally managed io_context.

See also
  init_asio(io_context_ptr ptr)

Definition at line 252 of file endpoint.hpp.

## init_asio() [2/4]

template<typename config>

void websocketpp::transport::asio::endpoint< config >::init_asio | ( | io_context_ptr | ptr | ) |

inline

initialize asio transport with external io_context

Initialize the ASIO transport policy for this endpoint using the provided io_context object. asio_init must be called exactly once on any endpoint that uses transport::asio before it can be used.

Parameters

  ptr | A pointer to the io_context to use for asio events

Definition at line 213 of file endpoint.hpp.

## init_asio() [3/4]

template<typename config>

void websocketpp::transport::asio::endpoint< config >::init_asio | ( | io_context_ptr | ptr,
|  | lib::error_code & | ec )

inline

initialize asio transport with external io_context (exception free)

Initialize the ASIO transport policy for this endpoint using the provided io_context object. asio_init must be called exactly once on any endpoint that uses transport::asio before it can be used.

Parameters

  ptr | A pointer to the io_context to use for asio events
  ec | Set to indicate what error occurred, if any.

Definition at line 185 of file endpoint.hpp.

## init_asio() [4/4]

template<typename config>

void websocketpp::transport::asio::endpoint< config >::init_asio | ( | lib::error_code & | ec | ) |

inline

Initialize asio transport with internal io_context (exception free).

This method of initialization will allocate and use an internally managed io_context.

See also
  init_asio(io_context_ptr ptr)

Parameters

  ec | Set to indicate what error occurred, if any.

Definition at line 229 of file endpoint.hpp.

## init_logging()

template<typename config>

void websocketpp::transport::asio::endpoint< config >::init_logging | ( | const lib::shared_ptr< alog_type > & | a,
|  | const lib::shared_ptr< elog_type > & | e )

inline protected

Initialize logging.

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 848 of file endpoint.hpp.

## is_listening()

template<typename config>

bool websocketpp::transport::asio::endpoint< config >::is_listening | ( |  | ) | const

inline

Check if the endpoint is listening.

Returns
  Whether or not the endpoint is listening.

Definition at line 658 of file endpoint.hpp.

## is_secure()

template<typename config>

bool websocketpp::transport::asio::endpoint< config >::is_secure | ( |  | ) | const

inline

Return whether or not the endpoint produces secure connections.

Definition at line 172 of file endpoint.hpp.

## listen() [1/8]

template<typename config>
template<typename InternetProtocol>

void websocketpp::transport::asio::endpoint< config >::listen | ( | InternetProtocol const & | internet_protocol,
|  | uint16_t | port )

inline

Set up endpoint for listening with protocol and port.

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:

- IPv6 with mapped IPv4 for dual stack hosts lib::asio::ip::tcp::v6()
- IPv4 only: lib::asio::ip::tcp::v4()

Parameters

  internet_protocol | The internet protocol to use.
  port | The port to listen on.

Definition at line 589 of file endpoint.hpp.

## listen() [2/8]

template<typename config>
template<typename InternetProtocol>

void websocketpp::transport::asio::endpoint< config >::listen | ( | InternetProtocol const & | internet_protocol,
|  | uint16_t | port,
|  | lib::error_code & | ec )

inline

Set up endpoint for listening with protocol and port (exception free).

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:

- IPv6 with mapped IPv4 for dual stack hosts lib::asio::ip::tcp::v6()
- IPv4 only: lib::asio::ip::tcp::v4()

Parameters

  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 471 of file endpoint.hpp.

## listen() [3/8]

template<typename config>

void websocketpp::transport::asio::endpoint< config >::listen | ( | lib::asio::ip::tcp::endpoint< config > const & | ep | ) |

inline

Set up endpoint for listening manually.

Bind the internal acceptor using the settings specified by the endpoint e

Parameters

  ep | An endpoint to read settings from

Definition at line 569 of file endpoint.hpp.

## listen() [4/8]

template<typename config>

void websocketpp::transport::asio::endpoint< config >::listen | ( | lib::asio::ip::tcp::endpoint< config > const & | ep,
|  | lib::error_code & | ec )

inline

Set up endpoint for listening manually (exception free).

Bind the internal acceptor using the specified settings. The endpoint must have been initialized by calling init_asio before listening.

Parameters

  ep | An endpoint to read settings from
  ec | Set to indicate what error occurred, if any.

Definition at line 416 of file endpoint.hpp.

## listen() [5/8]

template<typename config>

void websocketpp::transport::asio::endpoint< config >::listen | ( | std::string const & | host,
|  | std::string const & | service )

inline

Set up endpoint for listening on a host and service.

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 the ip::basic_resolver::resolve function.

The endpoint must have been initialized by calling init_asio before listening.

Once listening the underlying io_context will be kept open indefinitely. Calling endpoint::stop_listening will stop the endpoint from accepting new connections. See the documentation for stop listening for more details about shutting down Asio Transport based endpoints.

See also
  stop_listening()

Parameters

  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 633 of file endpoint.hpp.

## listen() [6/8]

template<typename config>

void websocketpp::transport::asio::endpoint< config >::listen | ( | std::string const & | host,
|  | std::string const & | service,
|  | lib::error_code & | ec )

inline

Set up endpoint for listening on a host and service (exception free).

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 the ip::basic_resolver::resolve function.

The endpoint must have been initialized by calling init_asio before listening.

Once listening the underlying io_context will be kept open indefinitely. Calling endpoint::stop_listening will stop the endpoint from accepting new connections. See the documentation for stop listening for more details about shutting down Asio Transport based endpoints.

See also
  stop_listening(lib::error_code &)

Parameters

  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 516 of file endpoint.hpp.

## listen() [7/8]

template<typename config>

void websocketpp::transport::asio::endpoint< config >::listen | ( | uint16_t | port | ) |

inline

Set up endpoint for listening on a port.

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.

Parameters

  port | The port to listen on.
  ec | Set to indicate what error occurred, if any.

Definition at line 607 of file endpoint.hpp.

## listen() [8/8]

template<typename config>

void websocketpp::transport::asio::endpoint< config >::listen | ( | uint16_t | port,
|  | lib::error_code & | ec )

inline

Set up endpoint for listening on a port (exception free).

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.

Parameters

  port | The port to listen on.
  ec | Set to indicate what error occurred, if any.

Definition at line 490 of file endpoint.hpp.

## poll()

template<typename config>

std::size_t websocketpp::transport::asio::endpoint< config >::poll | ( |  | ) |

inline

wraps the poll method of the internal io_context object

Definition at line 681 of file endpoint.hpp.

## poll_one()

template<typename config>

std::size_t websocketpp::transport::asio::endpoint< config >::poll_one | ( |  | ) |

inline

wraps the poll_one method of the internal io_context object

Definition at line 686 of file endpoint.hpp.

## reset()

template<typename config>

void websocketpp::transport::asio::endpoint< config >::reset | ( |  | ) |

inline

wraps the restart method of the internal io_context object

Definition at line 691 of file endpoint.hpp.

## run()

template<typename config>

std::size_t websocketpp::transport::asio::endpoint< config >::run | ( |  | ) |

inline

wraps the run method of the internal io_context object

Definition at line 663 of file endpoint.hpp.

## run_one()

template<typename config>

std::size_t websocketpp::transport::asio::endpoint< config >::run_one | ( |  | ) |

inline

wraps the run_one method of the internal io_context object

Since
  0.3.0-alpha4

Definition at line 671 of file endpoint.hpp.

## set_listen_backlog()

template<typename config>

void websocketpp::transport::asio::endpoint< config >::set_listen_backlog | ( | int | backlog | ) |

inline

Sets the maximum length of the queue of pending connections.

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.

The default value is specified as *::asio::socket_base::max_listen_connections which uses the operating system defined maximum queue length. Your OS may restrict or silently lower this value. A value of zero may cause all connections to be rejected.

Since
  0.3.0

Parameters

  backlog | The maximum length of the queue of pending connections

Definition at line 346 of file endpoint.hpp.

## set_reuse_addr()

template<typename config>

void websocketpp::transport::asio::endpoint< config >::set_reuse_addr | ( | bool | value | ) |

inline

Sets whether to use the SO_REUSEADDR flag when opening listening sockets.

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. There may be security consequences to enabling this option.

New values affect future calls to listen only so set this value prior to calling listen.

The default is false.

Since
  0.3.0

Parameters

  value | Whether or not to use the SO_REUSEADDR option

Definition at line 367 of file endpoint.hpp.

## set_tcp_init_handler()

template<typename config>

void websocketpp::transport::asio::endpoint< config >::set_tcp_init_handler | ( | tcp_init_handler | h | ) |

inline

Sets the tcp pre init handler (deprecated).

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.

Deprecated
  Use set_tcp_pre_init_handler instead

Parameters

  h | The handler to call on tcp pre init.

Definition at line 306 of file endpoint.hpp.

## set_tcp_post_init_handler()

template<typename config>

void websocketpp::transport::asio::endpoint< config >::set_tcp_post_init_handler | ( | tcp_init_handler | h | ) |

inline

Sets the tcp post init handler.

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.

Since
  0.3.0

Parameters

  h | The handler to call on tcp post init.

Definition at line 321 of file endpoint.hpp.

## set_tcp_pre_bind_handler()

template<typename config>

void websocketpp::transport::asio::endpoint< config >::set_tcp_pre_bind_handler | ( | tcp_pre_bind_handler | h | ) |

inline

Sets the tcp pre bind handler.

The tcp pre bind handler is called after the listen acceptor has been created but before the socket bind is performed.

Since
  0.8.0

Parameters

  h | The handler to call on tcp pre bind init.

Definition at line 278 of file endpoint.hpp.

## set_tcp_pre_init_handler()

template<typename config>

void websocketpp::transport::asio::endpoint< config >::set_tcp_pre_init_handler | ( | tcp_init_handler | h | ) |

inline

Sets the tcp pre init handler.

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.

Since
  0.3.0

Parameters

  h | The handler to call on tcp pre init.

Definition at line 292 of file endpoint.hpp.

## set_timer()

template<typename config>

timer_ptr websocketpp::transport::asio::endpoint< config >::set_timer | ( | long | duration,
|  | timer_handler | callback )

inline

Call back a function after a period of time.

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.

Parameters

  duration | Length of time to wait in milliseconds
  callback | The function to call back when the timer has expired

Returns
  A handle that can be used to cancel the timer if it is no longer needed.

Definition at line 740 of file endpoint.hpp.

## start_perpetual()

template<typename config>

void websocketpp::transport::asio::endpoint< config >::start_perpetual | ( |  | ) |

inline

Marks the endpoint as perpetual, stopping it from exiting when empty.

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

Since
  0.3.0

Definition at line 712 of file endpoint.hpp.

## stop()

template<typename config>

void websocketpp::transport::asio::endpoint< config >::stop | ( |  | ) |

inline

wraps the stop method of the internal io_context object

Definition at line 676 of file endpoint.hpp.

## stop_listening() [1/2]

template<typename config>

void websocketpp::transport::asio::endpoint< config >::stop_listening | ( |  | ) |

inline

Stop listening.

Stop listening and accepting new connections. This will not end any existing connections.

Since
  0.3.0-alpha4

Definition at line 647 of file endpoint.hpp.

## stop_listening() [2/2]

template<typename config>

void websocketpp::transport::asio::endpoint< config >::stop_listening | ( | lib::error_code & | ec | ) |

inline

Stop listening (exception free).

Stop listening and accepting new connections.

If the endpoint needs to shut down fully (i.e. close all connections) this member function is necessary but not sufficient. In addition to stopping listening, individual connections will need to be ended via their respective connection::close.

For more details on clean closing, please refer to Cleanly closing Asio Transport based endpoints

Since
  0.3.0-alpha4

Parameters

  ec | A status code indicating an error, if any.

Definition at line 546 of file endpoint.hpp.

## stop_perpetual()

template<typename config>

void websocketpp::transport::asio::endpoint< config >::stop_perpetual | ( |  | ) |

inline

Clears the endpoint's perpetual flag, allowing it to exit when empty.

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.

Since
  0.3.0

Definition at line 724 of file endpoint.hpp.

## stopped()

template<typename config>

bool websocketpp::transport::asio::endpoint< config >::stopped | ( |  | ) | const

inline

wraps the stopped method of the internal io_context object

Definition at line 696 of file endpoint.hpp.

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

- websocketpp/transport/asio/endpoint.hpp