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

#include <socket.hpp>

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

Public Member Functions

 TCPSocket (net::StreamSocket &sock, unsigned int buf_size)
 
 ~TCPSocket ()
 
std::string get_address ()
 
unsigned short get_port ()
 
unsigned int get_buf_size ()
 
int read (char *buf, unsigned int len, long timeout_seconds)
 
std::string read (long timeout_seconds=NO_TIMEOUT)
 
void write (std::string msg, bool new_line)
 
void write (fs::path file)
 
void write (unsigned int len, char *buf)
 
- Public Member Functions inherited from adaptyst::Socket
virtual ~Socket ()
 
- Public Member Functions inherited from adaptyst::Connection
virtual ~Connection ()
 

Protected Member Functions

void close ()
 

Detailed Description

A class describing a TCP socket.

Constructor & Destructor Documentation

◆ TCPSocket()

adaptyst::TCPSocket::TCPSocket ( net::StreamSocket & sock,
unsigned int buf_size )
inline

Constructs a TCPSocket object.

Parameters
sockThe Poco::Net::StreamSocket object corresponding to the already-established TCP socket.
buf_sizeThe buffer size for communication, in bytes.

◆ ~TCPSocket()

adaptyst::TCPSocket::~TCPSocket ( )
inline

Member Function Documentation

◆ close()

void adaptyst::TCPSocket::close ( )
protectedvirtual

Closes the connection.

Implements adaptyst::Socket.

◆ get_address()

std::string adaptyst::TCPSocket::get_address ( )
inlinevirtual

Gets the socket address string.

Implements adaptyst::Socket.

◆ get_buf_size()

unsigned int adaptyst::TCPSocket::get_buf_size ( )
inlinevirtual

Gets the buffer size for communication, in bytes.

Implements adaptyst::Socket.

◆ get_port()

unsigned short adaptyst::TCPSocket::get_port ( )
inlinevirtual

Gets the port of the socket.

Implements adaptyst::Socket.

◆ read() [1/2]

int adaptyst::TCPSocket::read ( char * buf,
unsigned int len,
long timeout_seconds )
inlinevirtual

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::Socket.

◆ read() [2/2]

std::string adaptyst::TCPSocket::read ( long timeout_seconds = NO_TIMEOUT)
inlinevirtual

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::Socket.

◆ write() [1/3]

void adaptyst::TCPSocket::write ( fs::path file)
inlinevirtual

Writes a file to the connection.

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

Implements adaptyst::Socket.

◆ write() [2/3]

void adaptyst::TCPSocket::write ( std::string msg,
bool new_line )
inlinevirtual

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::Socket.

◆ write() [3/3]

void adaptyst::TCPSocket::write ( unsigned int len,
char * buf )
inlinevirtual

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::Socket.


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