xrpld
Loading...
Searching...
No Matches
AutoSocket Class Reference

#include <AutoSocket.h>

Collaboration diagram for AutoSocket:

Public Types

using ssl_socket = boost::asio::ssl::stream<boost::asio::ip::tcp::socket>
using endpoint_type = boost::asio::ip::tcp::socket::endpoint_type
using socket_ptr = std::unique_ptr<ssl_socket>
using plain_socket = ssl_socket::next_layer_type
using lowest_layer_type = ssl_socket::lowest_layer_type
using handshake_type = ssl_socket::handshake_type
using error_code = boost::system::error_code
using callback = std::function<void(error_code)>

Public Member Functions

 AutoSocket (boost::asio::io_context &s, boost::asio::ssl::context &c, bool secureOnly, bool plainOnly)
 AutoSocket (boost::asio::io_context &s, boost::asio::ssl::context &c)
bool isSecure () const
ssl_socketsslSocket ()
plain_socketplainSocket ()
beast::IP::Endpoint localEndpoint ()
beast::IP::Endpoint remoteEndpoint ()
lowest_layer_typelowestLayer ()
void swap (AutoSocket &s) noexcept
boost::system::error_code cancel (boost::system::error_code &ec)
void asyncHandshake (handshake_type type, callback cbFunc)
template<typename ShutdownHandler>
void asyncShutdown (ShutdownHandler handler)
template<typename Seq, typename Handler>
void asyncReadSome (Seq const &buffers, Handler handler)
template<typename Seq, typename Condition, typename Handler>
void asyncReadUntil (Seq const &buffers, Condition condition, Handler handler)
template<typename Allocator, typename Handler>
void asyncReadUntil (boost::asio::basic_streambuf< Allocator > &buffers, std::string const &delim, Handler handler)
template<typename Allocator, typename MatchCondition, typename Handler>
void asyncReadUntil (boost::asio::basic_streambuf< Allocator > &buffers, MatchCondition cond, Handler handler)
template<typename Buf, typename Handler>
void asyncWrite (Buf const &buffers, Handler handler)
template<typename Allocator, typename Handler>
void asyncWrite (boost::asio::basic_streambuf< Allocator > &buffers, Handler handler)
template<typename Buf, typename Condition, typename Handler>
void asyncRead (Buf const &buffers, Condition cond, Handler handler)
template<typename Allocator, typename Condition, typename Handler>
void asyncRead (boost::asio::basic_streambuf< Allocator > &buffers, Condition cond, Handler handler)
template<typename Buf, typename Handler>
void asyncRead (Buf const &buffers, Handler handler)
template<typename Seq, typename Handler>
void asyncWriteSome (Seq const &buffers, Handler handler)

Protected Member Functions

void handleAutodetect (callback cbFunc, error_code const &ec, size_t bytesTransferred)

Private Attributes

socket_ptr socket_
bool secure_
std::vector< char > buffer_
beast::Journal j_

Detailed Description

Definition at line 16 of file AutoSocket.h.

Member Typedef Documentation

◆ ssl_socket

using AutoSocket::ssl_socket = boost::asio::ssl::stream<boost::asio::ip::tcp::socket>

Definition at line 19 of file AutoSocket.h.

◆ endpoint_type

using AutoSocket::endpoint_type = boost::asio::ip::tcp::socket::endpoint_type

Definition at line 20 of file AutoSocket.h.

◆ socket_ptr

Definition at line 21 of file AutoSocket.h.

◆ plain_socket

using AutoSocket::plain_socket = ssl_socket::next_layer_type

Definition at line 22 of file AutoSocket.h.

◆ lowest_layer_type

using AutoSocket::lowest_layer_type = ssl_socket::lowest_layer_type

Definition at line 23 of file AutoSocket.h.

◆ handshake_type

using AutoSocket::handshake_type = ssl_socket::handshake_type

Definition at line 24 of file AutoSocket.h.

◆ error_code

using AutoSocket::error_code = boost::system::error_code

Definition at line 25 of file AutoSocket.h.

◆ callback

Definition at line 26 of file AutoSocket.h.

Constructor & Destructor Documentation

◆ AutoSocket() [1/2]

AutoSocket::AutoSocket ( boost::asio::io_context & s,
boost::asio::ssl::context & c,
bool secureOnly,
bool plainOnly )

Definition at line 29 of file AutoSocket.h.

◆ AutoSocket() [2/2]

AutoSocket::AutoSocket ( boost::asio::io_context & s,
boost::asio::ssl::context & c )

Definition at line 41 of file AutoSocket.h.

Member Function Documentation

◆ isSecure()

bool AutoSocket::isSecure ( ) const
nodiscard

Definition at line 47 of file AutoSocket.h.

◆ sslSocket()

ssl_socket & AutoSocket::sslSocket ( )

Definition at line 52 of file AutoSocket.h.

◆ plainSocket()

plain_socket & AutoSocket::plainSocket ( )

Definition at line 57 of file AutoSocket.h.

◆ localEndpoint()

beast::IP::Endpoint AutoSocket::localEndpoint ( )

Definition at line 63 of file AutoSocket.h.

◆ remoteEndpoint()

beast::IP::Endpoint AutoSocket::remoteEndpoint ( )

Definition at line 69 of file AutoSocket.h.

◆ lowestLayer()

lowest_layer_type & AutoSocket::lowestLayer ( )

Definition at line 75 of file AutoSocket.h.

◆ swap()

void AutoSocket::swap ( AutoSocket & s)
noexcept

Definition at line 81 of file AutoSocket.h.

◆ cancel()

boost::system::error_code AutoSocket::cancel ( boost::system::error_code & ec)

Definition at line 89 of file AutoSocket.h.

◆ asyncHandshake()

void AutoSocket::asyncHandshake ( handshake_type type,
callback cbFunc )

Definition at line 95 of file AutoSocket.h.

◆ asyncShutdown()

template<typename ShutdownHandler>
void AutoSocket::asyncShutdown ( ShutdownHandler handler)

Definition at line 126 of file AutoSocket.h.

◆ asyncReadSome()

template<typename Seq, typename Handler>
void AutoSocket::asyncReadSome ( Seq const & buffers,
Handler handler )

Definition at line 149 of file AutoSocket.h.

◆ asyncReadUntil() [1/3]

template<typename Seq, typename Condition, typename Handler>
void AutoSocket::asyncReadUntil ( Seq const & buffers,
Condition condition,
Handler handler )

Definition at line 163 of file AutoSocket.h.

◆ asyncReadUntil() [2/3]

template<typename Allocator, typename Handler>
void AutoSocket::asyncReadUntil ( boost::asio::basic_streambuf< Allocator > & buffers,
std::string const & delim,
Handler handler )

Definition at line 177 of file AutoSocket.h.

◆ asyncReadUntil() [3/3]

template<typename Allocator, typename MatchCondition, typename Handler>
void AutoSocket::asyncReadUntil ( boost::asio::basic_streambuf< Allocator > & buffers,
MatchCondition cond,
Handler handler )

Definition at line 194 of file AutoSocket.h.

◆ asyncWrite() [1/2]

template<typename Buf, typename Handler>
void AutoSocket::asyncWrite ( Buf const & buffers,
Handler handler )

Definition at line 211 of file AutoSocket.h.

◆ asyncWrite() [2/2]

template<typename Allocator, typename Handler>
void AutoSocket::asyncWrite ( boost::asio::basic_streambuf< Allocator > & buffers,
Handler handler )

Definition at line 225 of file AutoSocket.h.

◆ asyncRead() [1/3]

template<typename Buf, typename Condition, typename Handler>
void AutoSocket::asyncRead ( Buf const & buffers,
Condition cond,
Handler handler )

Definition at line 239 of file AutoSocket.h.

◆ asyncRead() [2/3]

template<typename Allocator, typename Condition, typename Handler>
void AutoSocket::asyncRead ( boost::asio::basic_streambuf< Allocator > & buffers,
Condition cond,
Handler handler )

Definition at line 253 of file AutoSocket.h.

◆ asyncRead() [3/3]

template<typename Buf, typename Handler>
void AutoSocket::asyncRead ( Buf const & buffers,
Handler handler )

Definition at line 267 of file AutoSocket.h.

◆ asyncWriteSome()

template<typename Seq, typename Handler>
void AutoSocket::asyncWriteSome ( Seq const & buffers,
Handler handler )

Definition at line 281 of file AutoSocket.h.

◆ handleAutodetect()

void AutoSocket::handleAutodetect ( callback cbFunc,
error_code const & ec,
size_t bytesTransferred )
protected

Definition at line 295 of file AutoSocket.h.

Member Data Documentation

◆ socket_

socket_ptr AutoSocket::socket_
private

Definition at line 325 of file AutoSocket.h.

◆ secure_

bool AutoSocket::secure_
private

Definition at line 326 of file AutoSocket.h.

◆ buffer_

std::vector<char> AutoSocket::buffer_
private

Definition at line 327 of file AutoSocket.h.

◆ j_

beast::Journal AutoSocket::j_
private

Definition at line 328 of file AutoSocket.h.