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

#include <socket.hpp>

Inheritance diagram for adaptyst::Connection:
adaptyst::Socket adaptyst::TCPSocket

Public Member Functions

virtual ~Connection ()
 
virtual int read (char *buf, unsigned int len, long timeout_seconds)=0
 
virtual std::string read (long timeout_seconds=NO_TIMEOUT)=0
 
virtual void write (std::string msg, bool new_line=true)=0
 
virtual void write (fs::path file)=0
 
virtual void write (unsigned int len, char *buf)=0
 
virtual unsigned int get_buf_size ()=0
 

Protected Member Functions

virtual void close ()=0
 

Detailed Description

An interface describing a two-end connection.

Constructor & Destructor Documentation

◆ ~Connection()

virtual adaptyst::Connection::~Connection ( )
inlinevirtual

Member Function Documentation

◆ close()

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

Closes the connection.

Implemented in adaptyst::Socket, and adaptyst::TCPSocket.

◆ get_buf_size()

virtual unsigned int adaptyst::Connection::get_buf_size ( )
pure virtual

Gets the buffer size for communication, in bytes.

Implemented in adaptyst::Socket, and adaptyst::TCPSocket.

◆ read() [1/2]

virtual int adaptyst::Connection::read ( char * buf,
unsigned int len,
long timeout_seconds )
pure virtual

Reads data from the connection.

Parameters
bufA buffer where received data should be stored.
lenThe size of the buffer.
timeout_secondsA maximum number of seconds that can pass while waiting for the data.
Exceptions
TimeoutExceptionIn case of timeout (see timeout_seconds).
ConnectionExceptionIn case of any other errors.

Implemented in adaptyst::Socket, and adaptyst::TCPSocket.

◆ read() [2/2]

virtual std::string adaptyst::Connection::read ( long timeout_seconds = NO_TIMEOUT)
pure virtual

Reads a line from the connection.

Parameters
timeout_secondsA maximum number of seconds that can pass while waiting for the data. Use NO_TIMEOUT for no timeout.
Exceptions
TimeoutExceptionIn case of timeout (see timeout_seconds).
ConnectionExceptionIn case of any other errors.

Implemented in adaptyst::Socket, and adaptyst::TCPSocket.

◆ write() [1/3]

virtual void adaptyst::Connection::write ( fs::path file)
pure virtual

Writes a file to the connection.

Parameters
fileThe path to a file to be sent.
Exceptions
ConnectionExceptionIn case of any errors.

Implemented in adaptyst::Socket, and adaptyst::TCPSocket.

◆ write() [2/3]

virtual void adaptyst::Connection::write ( std::string msg,
bool new_line = true )
pure virtual

Writes a string to the connection.

Parameters
msgA string to be sent.
new_lineIndicates whether a newline character should be appended to the string.
Exceptions
ConnectionExceptionIn case of any errors.

Implemented in adaptyst::Socket, and adaptyst::TCPSocket.

◆ write() [3/3]

virtual void adaptyst::Connection::write ( unsigned int len,
char * buf )
pure virtual

Writes data to the connection.

Parameters
lenThe number of bytes to be sent.
bufA buffer storing data to be written. Its size must be equal to or greater than the number of bytes to be sent.

Implemented in adaptyst::Socket, and adaptyst::TCPSocket.


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