EHS
Loading...
Searching...
No Matches
ehs::BaseTCP Class Referenceabstract

#include <BaseTCP.h>

Inheritance diagram for ehs::BaseTCP:
ehs::TCP ehs::TCP ehs::SSL ehs::SSL

Public Member Functions

virtual ~BaseTCP ()=default
 
 BaseTCP ()
 Initializes the socket with the defaults.
 
 BaseTCP (IP ip)
 
 BaseTCP (BaseTCP &&tcp) noexcept
 
 BaseTCP (const BaseTCP &tcp)
 
BaseTCPoperator= (BaseTCP &&tcp) noexcept
 
BaseTCPoperator= (const BaseTCP &tcp)
 
virtual void Initialize ()=0
 Explicitly initialize the socket.
 
virtual void Release ()=0
 Explicitly release resources before it falls off the stack.
 
virtual void Bind (const Str_8 &address, UInt_16 port)=0
 
virtual void Listen ()=0
 
virtual BaseTCPAccept ()=0
 
virtual void Connect (const Str_8 &address, UInt_16 port)=0
 
virtual UInt_64 Send (const Byte *buffer, UInt_32 size)=0
 
virtual UInt_64 Receive (Byte *buffer, UInt_32 size)=0
 
void SendStr (const Str_8 &str)
 
void SendRes (const Response &res)
 
void SendReq (Request &req)
 
Response RecvRes ()
 
Request RecvReq ()
 
IP GetAddressType () const
 
Str_8 GetLocalAddress () const
 
unsigned short GetLocalPort () const
 
Str_8 GetRemoteAddress () const
 
UInt_16 GetRemotePort () const
 
bool IsConnection () const
 
bool IsBound () const
 
bool IsListening () const
 
bool IsConnected () const
 
virtual void SetBlocking (bool blocking)=0
 
virtual bool IsBlocking () const =0
 
virtual void SetIPv6Only (bool value)=0
 
virtual bool IsIPv6Only () const =0
 
virtual bool IsValid () const =0
 

Static Public Attributes

static const UInt_16 HTTPS_Port = 443
 
static const UInt_16 HTTP_Port = 80
 
static const UInt_16 MaxHeaderSize = 8192
 

Protected Attributes

IP ip
 
Str_8 localAddr
 
UInt_16 localPort
 
Str_8 remoteHostName
 
Str_8 remoteAddr
 
UInt_16 remotePort
 
bool connection
 
bool bound
 
bool listening
 
bool connected
 

Constructor & Destructor Documentation

◆ ~BaseTCP()

virtual ehs::BaseTCP::~BaseTCP ( )
virtualdefault

◆ BaseTCP() [1/4]

ehs::BaseTCP::BaseTCP ( )

Initializes the socket with the defaults.

◆ BaseTCP() [2/4]

ehs::BaseTCP::BaseTCP ( IP ip)

Properly initializes the socket.

Parameters
[in]typeThe ip version to initialize the socket with.

◆ BaseTCP() [3/4]

ehs::BaseTCP::BaseTCP ( BaseTCP && tcp)
noexcept

◆ BaseTCP() [4/4]

ehs::BaseTCP::BaseTCP ( const BaseTCP & tcp)

Member Function Documentation

◆ Accept()

virtual BaseTCP * ehs::BaseTCP::Accept ( )
pure virtual

Accepts the new incoming connection.

Note
Used for servers.

Implemented in ehs::SSL, ehs::TCP, and ehs::TCP.

◆ Bind()

virtual void ehs::BaseTCP::Bind ( const Str_8 & address,
UInt_16 port )
pure virtual

Binds to socket to a specified address and port.

Parameters
[in]addressThe ip address to bind to.
[in]portThe port to bind to.
Note
Used for servers.

Implemented in ehs::SSL, ehs::TCP, and ehs::TCP.

◆ Connect()

virtual void ehs::BaseTCP::Connect ( const Str_8 & address,
UInt_16 port )
pure virtual

Connects to a server at the specified address and port.

Parameters
[in]addressThe ip address to connect to.
[in]portThe port to connect to.
Note
Used for clients.

Implemented in ehs::SSL, ehs::TCP, and ehs::TCP.

◆ GetAddressType()

IP ehs::BaseTCP::GetAddressType ( ) const

Retrieves the sockets ip version.

Returns
The ip version.

◆ GetLocalAddress()

Str_8 ehs::BaseTCP::GetLocalAddress ( ) const

Retrieves the bound ip address.

Returns
The ip address.

◆ GetLocalPort()

unsigned short ehs::BaseTCP::GetLocalPort ( ) const

Retrieves the bound port.

Returns
The port.

◆ GetRemoteAddress()

Str_8 ehs::BaseTCP::GetRemoteAddress ( ) const

Retrieves the ip address of the connected endpoint.

Returns
The ip address.

◆ GetRemotePort()

unsigned short ehs::BaseTCP::GetRemotePort ( ) const

Retrieves the port of the connected endpoint.

Returns
The port.

◆ Initialize()

virtual void ehs::BaseTCP::Initialize ( )
pure virtual

Explicitly initialize the socket.

Implemented in ehs::SSL, ehs::TCP, and ehs::TCP.

◆ IsBlocking()

virtual bool ehs::BaseTCP::IsBlocking ( ) const
pure virtual

Retrieves whether or not when receiving data blocks the thread.

Returns
The result.

Implemented in ehs::TCP, and ehs::TCP.

◆ IsBound()

bool ehs::BaseTCP::IsBound ( ) const

Retrieves whether of not this socket is bound to an ip address and port.

Returns
The result.

◆ IsConnected()

bool ehs::BaseTCP::IsConnected ( ) const

Retrieves whether or not this socket is connected to an endpoint.

Returns
The result.

◆ IsConnection()

bool ehs::BaseTCP::IsConnection ( ) const

Retrieves whether or not this socket is connected to a client endpoint.

Returns
The result.

◆ IsIPv6Only()

virtual bool ehs::BaseTCP::IsIPv6Only ( ) const
pure virtual

Implemented in ehs::TCP, and ehs::TCP.

◆ IsListening()

bool ehs::BaseTCP::IsListening ( ) const

Retrieves whether or not this socket is listening for incoming connections.

Returns
The result.

◆ IsValid()

virtual bool ehs::BaseTCP::IsValid ( ) const
pure virtual

Retrieves whether or not this socket was initialized.

Returns
The result.

Implemented in ehs::TCP, and ehs::TCP.

◆ Listen()

virtual void ehs::BaseTCP::Listen ( )
pure virtual

Listens for new incoming connections.

Note
Used for servers.

Implemented in ehs::TCP, and ehs::TCP.

◆ operator=() [1/2]

BaseTCP & ehs::BaseTCP::operator= ( BaseTCP && tcp)
noexcept

◆ operator=() [2/2]

BaseTCP & ehs::BaseTCP::operator= ( const BaseTCP & tcp)

◆ Receive()

virtual UInt_64 ehs::BaseTCP::Receive ( Byte * buffer,
UInt_32 size )
pure virtual

Receives data from the connected endpoint.

Parameters
[out]bufferThe incoming data from the endpoint.
[in]sizeThe max size of the buffer in bytes to store the data.
Returns
The size of the incoming data in bytes.

Implemented in ehs::SSL, ehs::TCP, and ehs::TCP.

◆ RecvReq()

Request ehs::BaseTCP::RecvReq ( )

Receives a HTTP request from the connected endpoint.

Returns
The request received.

◆ RecvRes()

Response ehs::BaseTCP::RecvRes ( )

Receives a HTTP response from the connected endpoint.

Returns
The response received.

◆ Release()

virtual void ehs::BaseTCP::Release ( )
pure virtual

Explicitly release resources before it falls off the stack.

Implemented in ehs::SSL, ehs::TCP, and ehs::TCP.

◆ Send()

virtual UInt_64 ehs::BaseTCP::Send ( const Byte * buffer,
UInt_32 size )
pure virtual

Sends data to the connected endpoint.

Parameters
[in]bufferThe data to send to the endpoint.
[in]sizeThe size in bytes of data being sent.

Implemented in ehs::SSL, ehs::TCP, and ehs::TCP.

◆ SendReq()

void ehs::BaseTCP::SendReq ( Request & req)

Sends a HTTP request to the connected endpoint.

Parameters
[in]reqThe request to send.

◆ SendRes()

void ehs::BaseTCP::SendRes ( const Response & res)

Sends a HTTP response to the connected endpoint.

Parameters
[in]resThe response to send.

◆ SendStr()

void ehs::BaseTCP::SendStr ( const Str_8 & str)

Sends a string to the connected endpoint.

Parameters
[in]strThe string to send to the endpoint.

◆ SetBlocking()

virtual void ehs::BaseTCP::SetBlocking ( bool blocking)
pure virtual

Sets whether or not the socket blocks the thread when receiving data.

Parameters
[in]blockingWhether or not to block.

Implemented in ehs::TCP, and ehs::TCP.

◆ SetIPv6Only()

virtual void ehs::BaseTCP::SetIPv6Only ( bool value)
pure virtual

Implemented in ehs::TCP, and ehs::TCP.

Member Data Documentation

◆ bound

bool ehs::BaseTCP::bound
protected

◆ connected

bool ehs::BaseTCP::connected
protected

◆ connection

bool ehs::BaseTCP::connection
protected

◆ HTTP_Port

const UInt_16 ehs::BaseTCP::HTTP_Port = 80
static

◆ HTTPS_Port

const UInt_16 ehs::BaseTCP::HTTPS_Port = 443
static

◆ ip

IP ehs::BaseTCP::ip
protected

◆ listening

bool ehs::BaseTCP::listening
protected

◆ localAddr

Str_8 ehs::BaseTCP::localAddr
protected

◆ localPort

UInt_16 ehs::BaseTCP::localPort
protected

◆ MaxHeaderSize

const UInt_16 ehs::BaseTCP::MaxHeaderSize = 8192
static

◆ remoteAddr

Str_8 ehs::BaseTCP::remoteAddr
protected

◆ remoteHostName

Str_8 ehs::BaseTCP::remoteHostName
protected

◆ remotePort

UInt_16 ehs::BaseTCP::remotePort
protected

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