EHS
ehs::TCP Class Reference

A wrapper class for the transmission control protocol socket. More...

#include <TCP_BSD.h>

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

Public Member Functions

 ~TCP () override
 Frees any native handles. More...
 
 TCP ()
 Default members initialization. More...
 
 TCP (IP IP)
 
 TCP (TCP &&tcp) noexcept
 
 TCP (const TCP &tcp)
 
TCPoperator= (TCP &&tcp) noexcept
 
TCPoperator= (const TCP &tcp)
 
void Initialize () override
 Explicitly initialize the socket. More...
 
void Release () override
 Frees native handles and uninitializes them. More...
 
void Bind (const Str_8 &address, UInt_16 port) override
 
void Listen () override
 Listens for incoming connections. Used for servers or PtP. More...
 
TCPAccept () override
 
void Connect (const Str_8 &address, UInt_16 port) override
 
UInt_64 Send (const Byte *buffer, UInt_32 size) override
 
UInt_64 Receive (Byte *buffer, UInt_32 size) override
 
void SetBlocking (bool blocking) override
 
bool IsBlocking () const override
 
void SetIPv6Only (bool value) override
 
bool IsIPv6Only () const override
 
bool IsValid () const override
 
 ~TCP () override
 Frees any native handles. More...
 
 TCP ()
 Default members initialization. More...
 
 TCP (IP IP)
 
 TCP (TCP &&tcp) noexcept
 
 TCP (const TCP &tcp)
 
TCPoperator= (TCP &&tcp) noexcept
 
TCPoperator= (const TCP &tcp)
 
void Initialize () override
 Explicitly initialize the socket. More...
 
void Release () override
 Frees native handles and uninitializes them. More...
 
void Bind (const Str_8 &address, UInt_16 port) override
 
void Listen () override
 Listens for incoming connections. Used for servers or PtP. More...
 
TCPAccept () override
 
void Connect (const Str_8 &address, UInt_16 port) override
 
UInt_64 Send (const Byte *buffer, UInt_32 size) override
 
UInt_64 Receive (Byte *buffer, UInt_32 size) override
 
void SetBlocking (bool blocking) override
 
bool IsBlocking () const override
 
void SetIPv6Only (bool value) override
 
bool IsIPv6Only () const override
 
bool IsValid () const override
 
- Public Member Functions inherited from ehs::BaseTCP
virtual ~BaseTCP ()=default
 
 BaseTCP ()
 Initializes the socket with the defaults. More...
 
 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. More...
 
virtual void Release ()=0
 Explicitly release resources before it falls off the stack. More...
 
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
 

Protected Attributes

Socket hdl
 
- Protected Attributes inherited from ehs::BaseTCP
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
 

Additional Inherited Members

- Static Public Attributes inherited from ehs::BaseTCP
static const UInt_16 HTTPS_Port = 443
 
static const UInt_16 HTTP_Port = 80
 
static const UInt_16 MaxHeaderSize = 8192
 

Detailed Description

A wrapper class for the transmission control protocol socket.

Constructor & Destructor Documentation

◆ ~TCP() [1/2]

ehs::TCP::~TCP ( )
override

Frees any native handles.

◆ TCP() [1/8]

ehs::TCP::TCP ( )

Default members initialization.

◆ TCP() [2/8]

ehs::TCP::TCP ( IP  IP)

◆ TCP() [3/8]

ehs::TCP::TCP ( TCP &&  tcp)
noexcept

◆ TCP() [4/8]

ehs::TCP::TCP ( const TCP tcp)

Copies some members from the given TCP object.

Parameters
[in]tcpThe TCP object to copy from.

◆ ~TCP() [2/2]

ehs::TCP::~TCP ( )
override

Frees any native handles.

◆ TCP() [5/8]

ehs::TCP::TCP ( )

Default members initialization.

◆ TCP() [6/8]

ehs::TCP::TCP ( IP  IP)

◆ TCP() [7/8]

ehs::TCP::TCP ( TCP &&  tcp)
noexcept

◆ TCP() [8/8]

ehs::TCP::TCP ( const TCP tcp)

Copies some members from the given TCP object.

Parameters
[in]tcpThe TCP object to copy from.

Member Function Documentation

◆ Accept() [1/2]

TCP * ehs::TCP::Accept ( )
overridevirtual

Accepts an incoming connection. Used for servers or PtP.

Returns
The accepted client object.

Implements ehs::BaseTCP.

◆ Accept() [2/2]

TCP * ehs::TCP::Accept ( )
overridevirtual

Accepts an incoming connection. Used for servers or PtP.

Returns
The accepted client object.

Implements ehs::BaseTCP.

◆ Bind() [1/2]

void ehs::TCP::Bind ( const Str_8 address,
UInt_16  port 
)
overridevirtual

Binds the UDP socket to a local address and port.

Parameters
[in]addressThe local IPv4 or IPv6 address to bind to. Resolves domain names. The given address can be empty, "127.0.0.1", or "localhost" to automatically find the appropriate device.
[in]portThe port to bind to.
Note
Requires the port given to be forwarded if this is called.

Implements ehs::BaseTCP.

◆ Bind() [2/2]

void ehs::TCP::Bind ( const Str_8 address,
UInt_16  port 
)
overridevirtual

Binds the UDP socket to a local address and port.

Parameters
[in]addressThe local IPv4 or IPv6 address to bind to. Resolves domain names. The given address can be empty, "127.0.0.1", or "localhost" to automatically find the appropriate device.
[in]portThe port to bind to.
Note
Requires the port given to be forwarded if this is called.

Implements ehs::BaseTCP.

◆ Connect() [1/2]

void ehs::TCP::Connect ( const Str_8 address,
UInt_16  port 
)
overridevirtual

Connects to a TCP Socket that listens for incoming connections. Used for clients or PtP.

Parameters
addressThe address of the listening TCP socket. Resolves domain names. The given address can be empty, "127.0.0.1", or "localhost" to automatically find the appropriate device.
portThe port of the listening TCP socket.

Implements ehs::BaseTCP.

◆ Connect() [2/2]

void ehs::TCP::Connect ( const Str_8 address,
UInt_16  port 
)
overridevirtual

Connects to a TCP Socket that listens for incoming connections. Used for clients or PtP.

Parameters
addressThe address of the listening TCP socket. Resolves domain names. The given address can be empty, "127.0.0.1", or "localhost" to automatically find the appropriate device.
portThe port of the listening TCP socket.

Implements ehs::BaseTCP.

◆ Initialize() [1/2]

void ehs::TCP::Initialize ( )
overridevirtual

Explicitly initialize the socket.

Implements ehs::BaseTCP.

◆ Initialize() [2/2]

void ehs::TCP::Initialize ( )
overridevirtual

Explicitly initialize the socket.

Implements ehs::BaseTCP.

◆ IsBlocking() [1/2]

bool ehs::TCP::IsBlocking ( ) const
overridevirtual

Retrieves whether or not this socket will block when receiving data.

Returns
The result.

Implements ehs::BaseTCP.

◆ IsBlocking() [2/2]

bool ehs::TCP::IsBlocking ( ) const
overridevirtual

Retrieves whether or not this socket will block when receiving data.

Returns
The result.

Implements ehs::BaseTCP.

◆ IsIPv6Only() [1/2]

bool ehs::TCP::IsIPv6Only ( ) const
overridevirtual

Implements ehs::BaseTCP.

◆ IsIPv6Only() [2/2]

bool ehs::TCP::IsIPv6Only ( ) const
overridevirtual

Implements ehs::BaseTCP.

◆ IsValid() [1/2]

bool ehs::TCP::IsValid ( ) const
overridevirtual

Retrieves whether or not this socket was initialized.

Returns
The result.

Implements ehs::BaseTCP.

◆ IsValid() [2/2]

bool ehs::TCP::IsValid ( ) const
overridevirtual

Retrieves whether or not this socket was initialized.

Returns
The result.

Implements ehs::BaseTCP.

◆ Listen() [1/2]

void ehs::TCP::Listen ( )
overridevirtual

Listens for incoming connections. Used for servers or PtP.

Implements ehs::BaseTCP.

◆ Listen() [2/2]

void ehs::TCP::Listen ( )
overridevirtual

Listens for incoming connections. Used for servers or PtP.

Implements ehs::BaseTCP.

◆ operator=() [1/4]

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

Copies some members from the given TCP object.

Parameters
[in]tcpThe TCP object to copy from.
Returns
The TCP object that has been assigned to.

◆ operator=() [2/4]

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

Copies some members from the given TCP object.

Parameters
[in]tcpThe TCP object to copy from.
Returns
The TCP object that has been assigned to.

◆ operator=() [3/4]

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

◆ operator=() [4/4]

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

◆ Receive() [1/2]

UInt_64 ehs::TCP::Receive ( Byte buffer,
UInt_32  size 
)
overridevirtual

Receives data in a C-style array with raw functionality. Meaning no internal help outside of native functions besides error checking.

Parameters
[out]bufferThe C-style array to receive with.
[in]sizeThe size of the given C-style array.
Returns
The size of the data actually received in bytes.

Implements ehs::BaseTCP.

◆ Receive() [2/2]

UInt_64 ehs::TCP::Receive ( Byte buffer,
UInt_32  size 
)
overridevirtual

Receives data in a C-style array with raw functionality. Meaning no internal help outside of native functions besides error checking.

Parameters
[out]bufferThe C-style array to receive with.
[in]sizeThe size of the given C-style array.
Returns
The size of the data actually received in bytes.

Implements ehs::BaseTCP.

◆ Release() [1/2]

void ehs::TCP::Release ( )
overridevirtual

Frees native handles and uninitializes them.

Implements ehs::BaseTCP.

◆ Release() [2/2]

void ehs::TCP::Release ( )
overridevirtual

Frees native handles and uninitializes them.

Implements ehs::BaseTCP.

◆ Send() [1/2]

UInt_64 ehs::TCP::Send ( const Byte buffer,
UInt_32  size 
)
overridevirtual

Sends data in a C-style array with raw functionality. Meaning no internal help outside of native functions besides error checking.

Parameters
[in]bufferThe C-style array to send.
[in]sizeThe size of the given C-style array.
Returns
The size of the data actually sent in bytes.

Implements ehs::BaseTCP.

◆ Send() [2/2]

UInt_64 ehs::TCP::Send ( const Byte buffer,
UInt_32  size 
)
overridevirtual

Sends data in a C-style array with raw functionality. Meaning no internal help outside of native functions besides error checking.

Parameters
[in]bufferThe C-style array to send.
[in]sizeThe size of the given C-style array.
Returns
The size of the data actually sent in bytes.

Implements ehs::BaseTCP.

◆ SetBlocking() [1/2]

void ehs::TCP::SetBlocking ( bool  blocking)
overridevirtual

Sets whether or not receiving data blocks the next task.

Parameters
[in]blockingWhether or not to block.

Implements ehs::BaseTCP.

◆ SetBlocking() [2/2]

void ehs::TCP::SetBlocking ( bool  blocking)
overridevirtual

Sets whether or not receiving data blocks the next task.

Parameters
[in]blockingWhether or not to block.

Implements ehs::BaseTCP.

◆ SetIPv6Only() [1/2]

void ehs::TCP::SetIPv6Only ( bool  value)
overridevirtual

Implements ehs::BaseTCP.

◆ SetIPv6Only() [2/2]

void ehs::TCP::SetIPv6Only ( bool  value)
overridevirtual

Implements ehs::BaseTCP.

Member Data Documentation

◆ hdl

Socket ehs::TCP::hdl
protected

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