PandoraBotIRC  1.0.0
An irc bot that acts as a Pandora chatter bot
pbirc::irc::TCPConnection Class Reference

TCPConnection encapsulates a tcp connection with SFML sockets. More...

#include <TCPConnection.hpp>

Public Member Functions

 TCPConnection ()
 Default constructor. More...
 
 ~TCPConnection ()=default
 Default destructor. More...
 
 TCPConnection (TCPConnection const &)=delete
 
TCPConnectionoperator= (TCPConnection const &)
 
bool connect (std::string const &server_name, std::uint16_t const &port)
 Starts up the tcp connection. More...
 
void disconnect ()
 Disconnects the tcp connection. More...
 
std::uint16_t getLocalPort ()
 Get the port to which the socket is bound locally. More...
 
std::uint16_t getRemotePort ()
 Get the port of the connected peer to which the socket is connected. More...
 
 operator bool ()
 operator bool This function returns m_status. More...
 
TCPConnectionoperator<< (std::string const &rhs)
 operator << overload. More...
 
TCPConnectionoperator>> (std::string &rhs)
 operator >> overload. More...
 

Detailed Description

TCPConnection encapsulates a tcp connection with SFML sockets.

Example Usage

Possible output for the above example:

 

Constructor & Destructor Documentation

pbirc::irc::TCPConnection::TCPConnection ( )

Default constructor.

Does nothing but set 'm_status' to false.

pbirc::irc::TCPConnection::~TCPConnection ( )
default

Default destructor.

pbirc::irc::TCPConnection::TCPConnection ( TCPConnection const &  )
delete

Member Function Documentation

bool pbirc::irc::TCPConnection::connect ( std::string const &  server_name,
std::uint16_t const &  port 
)

Starts up the tcp connection.

Parameters
[in]server_namedomain name or IP of the server to connect to
[in]portthe port on the server to connect to
void pbirc::irc::TCPConnection::disconnect ( )

Disconnects the tcp connection.

std::uint16_t pbirc::irc::TCPConnection::getLocalPort ( )

Get the port to which the socket is bound locally.

This function only forwards sf::Socket::getLocalPort().

Returns
uint16_t representing the local port.
std::uint16_t pbirc::irc::TCPConnection::getRemotePort ( )

Get the port of the connected peer to which the socket is connected.

This function only forwards sf::Socket::getRemotePort().

Returns
uint16_t representing the remote port.
pbirc::irc::TCPConnection::operator bool ( )
inline

operator bool This function returns m_status.

Evaluates to true if all is good and the socket is connected. Evaluates to false if something has gone wrong or if the socket is disconnected.

TCPConnection & pbirc::irc::TCPConnection::operator<< ( std::string const &  rhs)

operator << overload.

Is used to send data to the server. This function will disconnect and set m_status to false upon error.

Ex: connection << "This is some text that will be sent to the server";

TCPConnection& pbirc::irc::TCPConnection::operator= ( TCPConnection const &  )
TCPConnection & pbirc::irc::TCPConnection::operator>> ( std::string &  rhs)

operator >> overload.

Is used to receive data from the server. This function will disconnect and set m_status to false upon error. The amount of data received at once by this function is limited by 'receive_buff_sz'. A received string will never be more than 'receive_buff_sz' characters in length, but may be less.

Ex: std::string data; connection >> data;


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