16#ifndef OPENVPN_ASIO_ASIOBOUNDSOCK_H
17#define OPENVPN_ASIO_ASIOBOUNDSOCK_H
26typedef openvpn_io::basic_stream_socket<openvpn_io::ip::tcp>
SocketBase;
31 explicit Socket(openvpn_io::io_context &io_context)
61 ret +=
v4.to_string();
68 ret +=
v6.to_string();
79 catch (
const std::exception &e)
86 template <
typename IP_ADDR>
107 template <
typename PARENT>
108 void post_open(PARENT *parent, openvpn_io::error_code &ec)
const
112 parent->set_option(openvpn_io::socket_base::reuse_address(
true), ec);
114 parent->bind(openvpn_io::ip::tcp::endpoint(
local_.to_asio(),
port_), ec);
120 return '[' +
local_.to_string() +
"]:" + std::to_string(
port_);
130 if (protocol == openvpn_io::ip::tcp::v4())
131 v4.post_open(
this, ec);
132 else if (protocol == openvpn_io::ip::tcp::v6())
133 v6.post_open(
this, ec);
void bind_local(const IP_ADDR &local, const unsigned short port)
std::string to_string() const
void post_open(PARENT *parent, openvpn_io::error_code &ec) const
void bind_local(const IP::Addr &addr, const unsigned short port=0)
virtual void async_connect_post_open(const protocol_type &protocol, openvpn_io::error_code &ec) override
Socket(openvpn_io::io_context &io_context)
std::string to_string() const
const IPv4::Addr & to_ipv4() const
const IPv6::Addr & to_ipv6() const
openvpn_io::basic_stream_socket< openvpn_io::ip::tcp > SocketBase
std::string to_string(const T &t)
Convert a value to a string.