Nets v3.0.0
SocketAddressView Struct Reference

Socket IP address instance view. More...

#include <socket.hpp>

Public Member Functions

 SocketAddressView (SocketAddress_T *instance) noexcept
 Creates a new socket IP address view.
void destroy () noexcept
 Destroys socket IP address instance.
SocketAddress_TgetInstance () const noexcept
 Returns socket IP address view instance.
SocketFamily getFamily () const noexcept
 Returns socket IP address family type.
size_t getIpSize () const noexcept
 Returns socket IP address byte array size.
bool isAny () const noexcept
 Returns true if socket IP address is any address.
bool isLoopback () const noexcept
 Returns true if socket IP address is loopback address.
bool isMappedV4 () const noexcept
 Returns true if socket IP address is IPv4 mapped IPv6.
const uint8_tgetIP () const noexcept
 Returns socket IP address byte array.
void setIP (const uint8_t *ip) noexcept
 Sets socket IP address byte array.
uint16_t getPort () const noexcept
 Returns socket IP address port number.
void setPort (uint16_t port) noexcept
 Sets socket IP address port number.
void getHost (char *host, size_t length) const noexcept
 Returns socket IP address numeric host name.
void getHost (std::string &host) const
 Returns socket IP address numeric host name.
void getService (char *service, size_t length) const noexcept
 Returns socket IP address numeric service name.
void getService (std::string &service) const
 Returns socket IP address numeric service name.
void getHostService (char *host, size_t hostLength, char *service, size_t serviceLength) const noexcept
 Returns socket IP address numeric host and service name.
void getHostService (std::string &host, std::string &service) const
 Returns socket IP address numeric host and service name.
 operator bool () const noexcept
 Returns true if socket IP address view is not null.

Static Public Member Functions

static NetsResult resolve (const char *host, const char *service, SocketFamily family, SocketType type, SocketAddressView *&socketAddresses, size_t &addressCount) noexcept
 Resolves a new socket IP address array. (Blocking call).
static void destroy (SocketAddressView *socketAddresses, size_t addressCount) noexcept
 Destroys resolved socket IP address array.
static void copy (SocketAddressView sourceAddress, SocketAddressView destinationAddress) noexcept
 Copies source socket IP address to the destination.
static int compare (SocketAddressView a, SocketAddressView b) noexcept
 Compares two socket IP addresses.

Protected Attributes

SocketAddress_Tinstance = nullptr

Detailed Description

Socket IP address instance view.

See the socket.h

Constructor & Destructor Documentation

◆ SocketAddressView()

SocketAddressView ( SocketAddress_T * instance)
inlinenoexcept

Creates a new socket IP address view.

Parameters
[in]instancetarget socket instance

Member Function Documentation

◆ destroy() [1/2]

void destroy ( )
inlinenoexcept

Destroys socket IP address instance.

See the destroySocketAddress().

◆ getFamily()

SocketFamily getFamily ( ) const
inlinenoexcept

Returns socket IP address family type.

See the getSocketAddressFamily().

◆ getIpSize()

size_t getIpSize ( ) const
inlinenoexcept

Returns socket IP address byte array size.

See the getSocketAddressIpSize().

◆ isAny()

bool isAny ( ) const
inlinenoexcept

Returns true if socket IP address is any address.

See the isSocketAddressAny().

◆ isLoopback()

bool isLoopback ( ) const
inlinenoexcept

Returns true if socket IP address is loopback address.

See the isSocketAddressLoopback().

◆ isMappedV4()

bool isMappedV4 ( ) const
inlinenoexcept

Returns true if socket IP address is IPv4 mapped IPv6.

See the isSocketAddressMappedV4().

◆ getIP()

const uint8_t * getIP ( ) const
inlinenoexcept

Returns socket IP address byte array.

See the getSocketAddressIP().

◆ setIP()

void setIP ( const uint8_t * ip)
inlinenoexcept

Sets socket IP address byte array.

See the setSocketAddressIP().

Parameters
[in]iptarget IP address byte array

◆ getPort()

uint16_t getPort ( ) const
inlinenoexcept

Returns socket IP address port number.

See the getSocketAddressPort().

◆ setPort()

void setPort ( uint16_t port)
inlinenoexcept

Sets socket IP address port number.

See the setSocketAddressPort().

Parameters
porttarget IP address port number

◆ getHost() [1/2]

void getHost ( char * host,
size_t length ) const
inlinenoexcept

Returns socket IP address numeric host name.

See the getSocketAddressHost().

Parameters
[out]hostpointer to the host name string
lengthhost name string length (including null terminator)

◆ getHost() [2/2]

void getHost ( std::string & host) const
inline

Returns socket IP address numeric host name.

See the getSocketAddressHost().

Parameters
[out]hosttarget host name string

◆ getService() [1/2]

void getService ( char * service,
size_t length ) const
inlinenoexcept

Returns socket IP address numeric service name.

See the getSocketAddressService().

Parameters
[out]servicepointer to the service name string
lengthservice name string length (including null terminator)

◆ getService() [2/2]

void getService ( std::string & service) const
inline

Returns socket IP address numeric service name.

See the getSocketAddressService().

Parameters
[out]servicetarget service name string

◆ getHostService() [1/2]

void getHostService ( char * host,
size_t hostLength,
char * service,
size_t serviceLength ) const
inlinenoexcept

Returns socket IP address numeric host and service name.

See the getSocketAddressHostService().

Parameters
[out]hostpointer to the host name string
hostLengthhost name string length (including null terminator)
[out]servicepointer to the service name string
serviceLengthservice name string length (including null terminator)

◆ getHostService() [2/2]

void getHostService ( std::string & host,
std::string & service ) const
inline

Returns socket IP address numeric host and service name.

See the getSocketAddressHostService().

Parameters
[out]hosttarget host name string
[out]servicetarget service name string

◆ resolve()

NetsResult resolve ( const char * host,
const char * service,
SocketFamily family,
SocketType type,
SocketAddressView *& socketAddresses,
size_t & addressCount )
inlinestaticnoexcept

Resolves a new socket IP address array. (Blocking call).

See the resolveSocketAddresses().

Warning
This may be a slow running operation!
Returns
The operation NetsResult code.
Parameters
[in]hostsocket IP address host name string
[in]servicesocket IP address service name string (port)
familysocket IP address family type
typesocket communication protocol type
[out]socketAddressesreference to the socket address array
[out]addressCountreference to the socket address count

◆ destroy() [2/2]

void destroy ( SocketAddressView * socketAddresses,
size_t addressCount )
inlinestaticnoexcept

Destroys resolved socket IP address array.

See the destroySocketAddresses().

Parameters
[in]socketAddressessocket IP address array
addressCountsocket address count

◆ copy()

void copy ( SocketAddressView sourceAddress,
SocketAddressView destinationAddress )
inlinestaticnoexcept

Copies source socket IP address to the destination.

See the copySocketAddress().

Parameters
sourceAddresssource socket address instance
destinationAddressdestination socket address instance

◆ compare()

int compare ( SocketAddressView a,
SocketAddressView b )
inlinestaticnoexcept

Compares two socket IP addresses.

See the compareSocketAddress().

Parameters
[in]afirst socket address instance
[in]bsecond socket address instance