MeVisLab Toolbox Reference
asio::TcpSocket Class Reference

A TCP socket class implementing the asio::Socket interface. More...

#include <TcpSocket.h>

Inheritance diagram for asio::TcpSocket:
asio::Socket asio::TlsSocket

Public Member Functions

 TcpSocket (std::shared_ptr< Context > context)
 ~TcpSocket () override
template<typename ConnectCompletionHandler>
void async_connect (const std::string &host, const unsigned short port, ConnectCompletionHandler &&handler)
bool is_open () const
bool is_valid () const override
void async_read (void *buffer, const std::size_t buffer_size, const CompletionHandler &handler) override
void async_write (const void *buffer, const std::size_t buffer_size, const CompletionHandler &handler) override
void close () override
 TcpSocket (const TcpSocket &)=delete
TcpSocketoperator= (const TcpSocket &)=delete
Public Member Functions inherited from asio::Socket
virtual ~Socket ()=default

Protected Attributes

std::shared_ptr< Contextcontext
boost::asio::ip::tcp::socket socket

Friends

class TcpAcceptor

Additional Inherited Members

Public Types inherited from asio::Socket
using CompletionHandler = std::function<void(const ErrorCode&, const std::size_t )>

Detailed Description

A TCP socket class implementing the asio::Socket interface.

Synopsis:

auto context = std::make_shared<asio::Context>();
socket.async_connect("127.0.0.1", 8080, [] (const asio::ErrorCode& ec) {
if (!ec) {
// connection established!
}
});
context->run(); // this blocks (as usual) and normally done somewhere else.
A TCP socket class implementing the asio::Socket interface.
Definition TcpSocket.h:44
std::shared_ptr< Context > context
Definition TcpSocket.h:88
boost::asio::ip::tcp::socket socket
Definition TcpSocket.h:90
boost::system::error_code ErrorCode
Definition ErrorCodes.h:13

Definition at line 43 of file TcpSocket.h.

Constructor & Destructor Documentation

◆ TcpSocket() [1/2]

asio::TcpSocket::TcpSocket ( std::shared_ptr< Context > context)

References context.

Referenced by operator=(), and TcpSocket().

◆ ~TcpSocket()

asio::TcpSocket::~TcpSocket ( )
override

◆ TcpSocket() [2/2]

asio::TcpSocket::TcpSocket ( const TcpSocket & )
delete

References TcpSocket().

Member Function Documentation

◆ async_connect()

template<typename ConnectCompletionHandler>
void asio::TcpSocket::async_connect ( const std::string & host,
const unsigned short port,
ConnectCompletionHandler && handler )
inline

Definition at line 52 of file TcpSocket.h.

References socket.

◆ async_read()

void asio::TcpSocket::async_read ( void * buffer,
const std::size_t buffer_size,
const CompletionHandler & handler )
overridevirtual

Implements asio::Socket.

Reimplemented in asio::TlsSocket.

◆ async_write()

void asio::TcpSocket::async_write ( const void * buffer,
const std::size_t buffer_size,
const CompletionHandler & handler )
overridevirtual

Implements asio::Socket.

Reimplemented in asio::TlsSocket.

◆ close()

void asio::TcpSocket::close ( )
overridevirtual

Implements asio::Socket.

Reimplemented in asio::TlsSocket.

◆ is_open()

bool asio::TcpSocket::is_open ( ) const

◆ is_valid()

bool asio::TcpSocket::is_valid ( ) const
overridevirtual

Implements asio::Socket.

Reimplemented in asio::TlsSocket.

◆ operator=()

TcpSocket & asio::TcpSocket::operator= ( const TcpSocket & )
delete

References TcpSocket().

◆ TcpAcceptor

friend class TcpAcceptor
friend

Definition at line 86 of file TcpSocket.h.

References TcpAcceptor.

Referenced by TcpAcceptor.

Member Data Documentation

◆ context

std::shared_ptr<Context> asio::TcpSocket::context
protected

Definition at line 88 of file TcpSocket.h.

Referenced by TcpSocket().

◆ socket

boost::asio::ip::tcp::socket asio::TcpSocket::socket
protected

Definition at line 90 of file TcpSocket.h.

Referenced by asio::TcpAcceptor::async_accept(), and async_connect().


The documentation for this class was generated from the following file:
  • FMEstable/ReleaseMeVis/Projects/AsynchronousIO/Sources/asio/TcpSocket.h