EHS
Loading...
Searching...
No Matches
ehs::UDP Class Reference

A wrapper class for the user datagram protocol socket. More...

#include <UDP_BSD.h>

Inheritance diagram for ehs::UDP:
ehs::BaseUDP ehs::BaseUDP

Public Member Functions

 ~UDP () override
 Frees any native handles.
 
 UDP ()
 
 UDP (IP version)
 Default members initialization.
 
 UDP (UDP &&udp) noexcept
 
 UDP (const UDP &udp)
 
UDPoperator= (UDP &&udp) noexcept
 
UDPoperator= (const UDP &udp)
 
void Release () override
 Frees native handles and uninitializes them.
 
void Bind (const Endpoint &endpoint) override
 
UInt_64 Send (const Endpoint &endpoint, const Byte *data, UInt_64 size) override
 
UInt_64 Receive (Endpoint *endpoint, Byte *data, UInt_64 size) override
 
void SetBlocking (bool blocking) override
 
bool IsBlocking () const override
 
void SetIPv6Only (bool value) override
 
bool IsIPv6Only () const override
 
bool IsValid () const override
 
 ~UDP () override
 Frees any native handles.
 
 UDP ()
 
 UDP (const IP IP)
 Default members initialization.
 
 UDP (UDP &&udp) noexcept
 
 UDP (const UDP &udp)
 
UDPoperator= (UDP &&udp) noexcept
 
UDPoperator= (const UDP &udp)
 
void Release () override
 Frees native handles and uninitializes them.
 
void Bind (const Endpoint &endpoint) override
 
UInt_64 Send (const Endpoint &endpoint, const Byte *data, UInt_64 size) override
 
UInt_64 Receive (Endpoint *endpoint, Byte *data, UInt_64 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::BaseUDP
virtual ~BaseUDP ()=default
 
 BaseUDP ()
 Initializes the socket with the defaults.
 
 BaseUDP (IP version)
 
 BaseUDP (BaseUDP &&udp) noexcept
 
 BaseUDP (const BaseUDP &udp)
 
BaseUDPoperator= (BaseUDP &&udp) noexcept
 
BaseUDPoperator= (const BaseUDP &udp)
 
bool IsBound () const
 
Endpoint GetLocalEndpoint () const
 

Additional Inherited Members

- Protected Attributes inherited from ehs::BaseUDP
Endpoint localEndpoint
 
bool bound
 

Detailed Description

A wrapper class for the user datagram protocol socket.

Constructor & Destructor Documentation

◆ ~UDP() [1/2]

ehs::UDP::~UDP ( )
override

Frees any native handles.

◆ UDP() [1/8]

ehs::UDP::UDP ( )

◆ UDP() [2/8]

ehs::UDP::UDP ( IP version)

Default members initialization.

◆ UDP() [3/8]

ehs::UDP::UDP ( UDP && udp)
noexcept

◆ UDP() [4/8]

ehs::UDP::UDP ( const UDP & udp)

Copies some members from the given UDP object.

Parameters
[in]udpThe UDP object to copy from.

◆ ~UDP() [2/2]

ehs::UDP::~UDP ( )
override

Frees any native handles.

◆ UDP() [5/8]

ehs::UDP::UDP ( )

◆ UDP() [6/8]

ehs::UDP::UDP ( const IP IP)

Default members initialization.

◆ UDP() [7/8]

ehs::UDP::UDP ( UDP && udp)
noexcept

◆ UDP() [8/8]

ehs::UDP::UDP ( const UDP & udp)

Copies some members from the given UDP object.

Parameters
[in]udpThe UDP object to copy from.

Member Function Documentation

◆ Bind() [1/2]

void ehs::UDP::Bind ( const Endpoint & endpoint)
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::BaseUDP.

◆ Bind() [2/2]

void ehs::UDP::Bind ( const Endpoint & endpoint)
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::BaseUDP.

◆ IsBlocking() [1/2]

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

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

Returns
The result.

Implements ehs::BaseUDP.

◆ IsBlocking() [2/2]

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

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

Returns
The result.

Implements ehs::BaseUDP.

◆ IsIPv6Only() [1/2]

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

Implements ehs::BaseUDP.

◆ IsIPv6Only() [2/2]

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

Implements ehs::BaseUDP.

◆ IsValid() [1/2]

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

Retrieves whether or not this socket was initialized.

Returns
The result.

Implements ehs::BaseUDP.

◆ IsValid() [2/2]

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

Retrieves whether or not this socket was initialized.

Returns
The result.

Implements ehs::BaseUDP.

◆ operator=() [1/4]

UDP & ehs::UDP::operator= ( const UDP & udp)

Copies some members from the given UDP object.

Parameters
[in]udpThe UDP object to copy from.
Returns
The UDP object that has been assigned to.

◆ operator=() [2/4]

UDP & ehs::UDP::operator= ( const UDP & udp)

Copies some members from the given UDP object.

Parameters
[in]udpThe UDP object to copy from.
Returns
The UDP object that has been assigned to.

◆ operator=() [3/4]

UDP & ehs::UDP::operator= ( UDP && udp)
noexcept

◆ operator=() [4/4]

UDP & ehs::UDP::operator= ( UDP && udp)
noexcept

◆ Receive() [1/2]

UInt_64 ehs::UDP::Receive ( Endpoint * endpoint,
Byte * data,
UInt_64 size )
overridevirtual

Receives data using the packet helper class.

Parameters
[out]addrThe Ipv4 or Ipv6 address of the sender.
[out]portThe port of the sender.
[out]dataThe C-style byte array received.
[in]sizeThe size of the pre-allocated C-style byte array.
Returns
The size of the data received.
Warning
The provided C-style byte array must be freed when finished using.

Implements ehs::BaseUDP.

◆ Receive() [2/2]

UInt_64 ehs::UDP::Receive ( Endpoint * endpoint,
Byte * data,
UInt_64 size )
overridevirtual

Receives data using the packet helper class.

Parameters
[out]addrThe Ipv4 or Ipv6 address of the sender.
[out]portThe port of the sender.
[out]dataThe C-style byte array received.
[in]sizeThe size of the pre-allocated C-style byte array.
Returns
The size of the data received.
Warning
The provided C-style byte array must be freed when finished using.

Implements ehs::BaseUDP.

◆ Release() [1/2]

void ehs::UDP::Release ( )
overridevirtual

Frees native handles and uninitializes them.

Implements ehs::BaseUDP.

◆ Release() [2/2]

void ehs::UDP::Release ( )
overridevirtual

Frees native handles and uninitializes them.

Implements ehs::BaseUDP.

◆ Send() [1/2]

UInt_64 ehs::UDP::Send ( const Endpoint & endpoint,
const Byte * data,
UInt_64 size )
overridevirtual

Sends data using a C-style byte array.

Parameters
[in]addrThe remote Ipv4 or Ipv6 address to send to. Resolves domain names. The given address can be empty, "127.0.0.1", or "localhost" to automatically find the appropriate device.
[in]portThe remote port to send to.
[in]dataThe C-style byte array to send.
[in]sizeThe size of the C-style byte array.
Note
The size of data to be sent cannot exceed "UDP::maxPayloadIpv4" or "UDP::maxPayloadIpv6".

Implements ehs::BaseUDP.

◆ Send() [2/2]

UInt_64 ehs::UDP::Send ( const Endpoint & endpoint,
const Byte * data,
UInt_64 size )
overridevirtual

Sends data using a C-style byte array.

Parameters
[in]addrThe remote Ipv4 or Ipv6 address to send to. Resolves domain names. The given address can be empty, "127.0.0.1", or "localhost" to automatically find the appropriate device.
[in]portThe remote port to send to.
[in]dataThe C-style byte array to send.
[in]sizeThe size of the C-style byte array.
Note
The size of data to be sent cannot exceed "UDP::maxPayloadIpv4" or "UDP::maxPayloadIpv6".

Implements ehs::BaseUDP.

◆ SetBlocking() [1/2]

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

Sets whether or not receiving data blocks the next task.

Parameters
[in]blockingWhether or not to block.

Implements ehs::BaseUDP.

◆ SetBlocking() [2/2]

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

Sets whether or not receiving data blocks the next task.

Parameters
[in]blockingWhether or not to block.

Implements ehs::BaseUDP.

◆ SetIPv6Only() [1/2]

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

Implements ehs::BaseUDP.

◆ SetIPv6Only() [2/2]

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

Implements ehs::BaseUDP.


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