Sane C++ Libraries
C++ Platform Abstraction Libraries
SC::SocketIPAddress Struct Reference

Native representation of an IP Address. More...

#include <SocketDescriptor.h>

Public Member Functions

 SocketIPAddress (SocketFlags::AddressFamily addressFamily=SocketFlags::AddressFamilyIPV4)
 Constructs an ip address from a given family (IPV4 or IPV6) More...
 
SocketFlags::AddressFamily getAddressFamily ()
 Get Address family of this ip address (IPV4 or IPV6) More...
 
Result fromAddressPort (StringView interfaceAddress, uint16_t port)
 Builds this SocketIPAddress parsing given address string and port. More...
 
uint32_t sizeOfHandle () const
 

Public Attributes

AlignedStorage< 28 > handle = {}
 

Friends

struct SocketServer
 
struct SocketClient
 

Detailed Description

Native representation of an IP Address.

Example:

SocketIPAddress address;
SC_TEST_EXPECT(not address.fromAddressPort("1223.22.44.1", 6666));
SC_TEST_EXPECT(address.fromAddressPort("127.0.0.1", 123));
SC_TEST_EXPECT(address.fromAddressPort("::1", 123));
#define SC_TEST_EXPECT(e)
Records a test expectation (eventually aborting or breaking o n failed test)
Definition: Testing.h:113
SocketIPAddress(SocketFlags::AddressFamily addressFamily=SocketFlags::AddressFamilyIPV4)
Constructs an ip address from a given family (IPV4 or IPV6)
Definition: SocketDescriptor.h:123

Constructor & Destructor Documentation

◆ SocketIPAddress()

SC::SocketIPAddress::SocketIPAddress ( SocketFlags::AddressFamily  addressFamily = SocketFlags::AddressFamilyIPV4)
inline

Constructs an ip address from a given family (IPV4 or IPV6)

Parameters
addressFamilyThe address family

Member Function Documentation

◆ fromAddressPort()

Result SC::SocketIPAddress::fromAddressPort ( StringView  interfaceAddress,
uint16_t  port 
)

Builds this SocketIPAddress parsing given address string and port.

Parameters
interfaceAddressA valid IPV4 or IPV6 address expressed as a string
portThe port to connect to
Returns
A valid Result if the address has been parsed successfully

◆ getAddressFamily()

SocketFlags::AddressFamily SC::SocketIPAddress::getAddressFamily ( )
inline

Get Address family of this ip address (IPV4 or IPV6)

Returns
The Ip Address Family of the given Socket

The documentation for this struct was generated from the following file: