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

#include <socket.hpp>

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

Public Member Functions

virtual ~Socket ()
 
virtual std::string get_address ()=0
 
virtual unsigned short get_port ()=0
 
virtual unsigned int get_buf_size ()=0
 
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
 
- Public Member Functions inherited from adaptyst::Connection
virtual ~Connection ()
 

Protected Member Functions

virtual void close ()=0
 

Detailed Description

An interface describing a network socket.

Constructor & Destructor Documentation

◆ ~Socket()

virtual adaptyst::Socket::~Socket ( )
inlinevirtual

Member Function Documentation

◆ close()

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

Closes the connection.

Implements adaptyst::Connection.

Implemented in adaptyst::TCPSocket.

◆ get_address()

virtual std::string adaptyst::Socket::get_address ( )
pure virtual

Gets the socket address string.

Implemented in adaptyst::TCPSocket.

◆ get_buf_size()

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

Gets the buffer size for communication, in bytes.

Implements adaptyst::Connection.

Implemented in adaptyst::TCPSocket.

◆ get_port()

virtual unsigned short adaptyst::Socket::get_port ( )
pure virtual

Gets the port of the socket.

Implemented in adaptyst::TCPSocket.

◆ read() [1/2]

virtual int adaptyst::Socket::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.

Implements adaptyst::Connection.

Implemented in adaptyst::TCPSocket.

◆ read() [2/2]

virtual std::string adaptyst::Socket::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.

Implements adaptyst::Connection.

Implemented in adaptyst::TCPSocket.

◆ write() [1/3]

virtual void adaptyst::Socket::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.

Implements adaptyst::Connection.

Implemented in adaptyst::TCPSocket.

◆ write() [2/3]

virtual void adaptyst::Socket::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.

Implements adaptyst::Connection.

Implemented in adaptyst::TCPSocket.

◆ write() [3/3]

virtual void adaptyst::Socket::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.

Implements adaptyst::Connection.

Implemented in adaptyst::TCPSocket.


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