Adaptyst
A comprehensive and architecture-agnostic performance analysis tool
Loading...
Searching...
No Matches
adaptyst::Acceptor Class Referenceabstract

#include <socket.hpp>

Inheritance diagram for adaptyst::Acceptor:
adaptyst::TCPAcceptor

Classes

class  Factory
 

Public Member Functions

std::unique_ptr< Connectionaccept (unsigned int buf_size, long timeout=NO_TIMEOUT)
 
virtual ~Acceptor ()
 
virtual std::string get_connection_instructions ()=0
 
virtual std::string get_type ()=0
 

Protected Member Functions

 Acceptor (int max_accepted)
 
virtual std::unique_ptr< Connectionaccept_connection (unsigned int buf_size, long timeout)=0
 
virtual void close ()=0
 

Detailed Description

A class describing a connection acceptor.

Constructor & Destructor Documentation

◆ Acceptor()

adaptyst::Acceptor::Acceptor ( int max_accepted)
inlineprotected

Constructs an Acceptor object.

Parameters
max_acceptedA maximum number of connections that the acceptor can accept during its lifetime. Use UNLIMITED_ACCEPTED for no limit.

◆ ~Acceptor()

virtual adaptyst::Acceptor::~Acceptor ( )
inlinevirtual

Member Function Documentation

◆ accept()

std::unique_ptr< Connection > adaptyst::Acceptor::accept ( unsigned int buf_size,
long timeout = NO_TIMEOUT )
inline

Accepts a new connection.

If the maximum number of accepted connections is reached, a runtime error is thrown immediately.

Parameters
buf_sizeThe buffer size for communication, in bytes.
timeoutThe maximum number of seconds the acceptor will wait for to accept a connection. Afterwards, TimeoutException will be thrown. Use NO_TIMEOUT to wait indefinitely for a connection.
Exceptions
std::runtime_errorWhen the maximum number of accepted connections is reached.
TimeoutExceptionWhen the timeout is reached.

◆ accept_connection()

virtual std::unique_ptr< Connection > adaptyst::Acceptor::accept_connection ( unsigned int buf_size,
long timeout )
protectedpure virtual

An internal method called by accept() accepting a new connection.

It should always return the new connection, regardless of the number of connections already accepted by the object.

Parameters
buf_sizeThe buffer size for communication, in bytes.
timeoutThe maximum number of seconds the acceptor will wait for to accept a connection. Afterwards, TimeoutException will be thrown. Use NO_TIMEOUT to wait indefinitely for a connection.

Implemented in adaptyst::TCPAcceptor.

◆ close()

virtual void adaptyst::Acceptor::close ( )
protectedpure virtual

Closes the acceptor.

Implemented in adaptyst::TCPAcceptor.

◆ get_connection_instructions()

virtual std::string adaptyst::Acceptor::get_connection_instructions ( )
pure virtual

Gets the instructions how the other end of the connection should connect to this end so that accept() can return a Connection-derived object.

These are in form of a "<field1>_<field2>_..._<fieldX>" string, where the number of fields and their content are implementation-dependent.

Implemented in adaptyst::TCPAcceptor.

◆ get_type()

virtual std::string adaptyst::Acceptor::get_type ( )
pure virtual

Gets the string describing the connection type of the acceptor (e.g. TCP).

Implemented in adaptyst::TCPAcceptor.


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