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

#include <AutoSocket.h>

Collaboration diagram for AutoSocket:

Public Types

using SslSocket = boost::asio::ssl::stream<boost::asio::ip::tcp::socket>
using EndpointType = boost::asio::ip::tcp::socket::endpoint_type
using SocketPtr = std::unique_ptr<SslSocket>
using PlainSocket = SslSocket::next_layer_type
using lowest_layer_type = SslSocket::lowest_layer_type
using HandshakeType = SslSocket::handshake_type
using ErrorCode = boost::system::error_code
using Callback = std::function<void(ErrorCode)>

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
SslSocket & sslSocket ()
PlainSocket & plainSocket ()
beast::ip::Endpoint localEndpoint ()
beast::ip::Endpoint remoteEndpoint ()
lowest_layer_type & lowestLayer ()
void swap (AutoSocket &s) noexcept
boost::system::error_code cancel (boost::system::error_code &ec)
void asyncHandshake (HandshakeType 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, ErrorCode const &ec, size_t bytesTransferred)

Private Attributes

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

Detailed Description

Definition at line 24 of file AutoSocket.h.

Member Typedef Documentation

◆ SslSocket

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

Definition at line 27 of file AutoSocket.h.

◆ EndpointType

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

Definition at line 28 of file AutoSocket.h.

◆ SocketPtr

Definition at line 29 of file AutoSocket.h.

◆ PlainSocket

using AutoSocket::PlainSocket = SslSocket::next_layer_type

Definition at line 30 of file AutoSocket.h.

◆ lowest_layer_type

using AutoSocket::lowest_layer_type = SslSocket::lowest_layer_type

Definition at line 32 of file AutoSocket.h.

◆ HandshakeType

using AutoSocket::HandshakeType = SslSocket::handshake_type

Definition at line 33 of file AutoSocket.h.

◆ ErrorCode

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

Definition at line 34 of file AutoSocket.h.

◆ Callback

Definition at line 35 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 38 of file AutoSocket.h.

◆ AutoSocket() [2/2]

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

Definition at line 50 of file AutoSocket.h.

Member Function Documentation

◆ isSecure()

bool AutoSocket::isSecure ( ) const
nodiscard

Definition at line 56 of file AutoSocket.h.

◆ sslSocket()

SslSocket & AutoSocket::sslSocket ( )

Definition at line 61 of file AutoSocket.h.

◆ plainSocket()

PlainSocket & AutoSocket::plainSocket ( )

Definition at line 66 of file AutoSocket.h.

◆ localEndpoint()

beast::ip::Endpoint AutoSocket::localEndpoint ( )

Definition at line 72 of file AutoSocket.h.

◆ remoteEndpoint()

beast::ip::Endpoint AutoSocket::remoteEndpoint ( )

Definition at line 78 of file AutoSocket.h.

◆ lowestLayer()

lowest_layer_type & AutoSocket::lowestLayer ( )

Definition at line 84 of file AutoSocket.h.

◆ swap()

void AutoSocket::swap ( AutoSocket & s)
noexcept

Definition at line 90 of file AutoSocket.h.

◆ cancel()

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

Definition at line 98 of file AutoSocket.h.

◆ asyncHandshake()

void AutoSocket::asyncHandshake ( HandshakeType type,
Callback cbFunc )

Definition at line 104 of file AutoSocket.h.

◆ asyncShutdown()

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

Definition at line 132 of file AutoSocket.h.

◆ asyncReadSome()

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

Definition at line 155 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 169 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 183 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 200 of file AutoSocket.h.

◆ asyncWrite() [1/2]

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

Definition at line 217 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 231 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 245 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 259 of file AutoSocket.h.

◆ asyncRead() [3/3]

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

Definition at line 273 of file AutoSocket.h.

◆ asyncWriteSome()

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

Definition at line 287 of file AutoSocket.h.

◆ handleAutodetect()

void AutoSocket::handleAutodetect ( Callback cbFunc,
ErrorCode const & ec,
size_t bytesTransferred )
protected

Definition at line 301 of file AutoSocket.h.

Member Data Documentation

◆ socket_

SocketPtr AutoSocket::socket_
private

Definition at line 331 of file AutoSocket.h.

◆ secure_

bool AutoSocket::secure_
private

Definition at line 332 of file AutoSocket.h.

◆ buffer_

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

Definition at line 333 of file AutoSocket.h.

◆ j_

beast::Journal AutoSocket::j_
private

Definition at line 334 of file AutoSocket.h.