![]() |
Gray C++ Libraries
0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
|
#include <cNetAddr.h>
Public Member Functions | |
cNetAddress () noexcept | |
cNetAddress (sa_family_t nFamily, NET_PORT_t wPort=k_NET_PORT_INVALID) noexcept | |
cNetAddress (in_addr ip, NET_PORT_t wPort=k_NET_PORT_INVALID) noexcept | |
cNetAddress (const char *pszAddr, bool bWait=false) | |
cNetAddress (const char *pszAddr, NET_PORT_t wPortDefault, bool bWait=false) | |
sa_family_t | get_Family () const noexcept |
socklen_t | get_AddrLen () const noexcept |
socklen_t & | ref_AddrLen () noexcept |
const sockaddr & | get_Addr () const noexcept |
const sockaddr & | ref_Addr () const noexcept |
sockaddr & | ref_Addr () noexcept |
bool | isAddrValid () const |
void | ResetAddr () noexcept |
COMPARE_t | CompareAddr (const cNetAddress &SocketAddr) const |
bool | operator== (const cNetAddress &SocketAddr) const |
bool | operator!= (const cNetAddress &SocketAddr) const |
HASHCODE_t | get_HashCodeHost () const noexcept |
HASHCODE_t | get_HashCode () const noexcept |
NET_PORT_t | get_PortNumber () const noexcept |
void | put_PortNumber (NET_PORT_t wPort) |
bool | isPortValid () const |
bool | put_PortServiceName (const char *pszPortServiceName) |
cStringA | get_PortServiceName () const |
const BYTE * | get_HostPtr () const |
BYTE * | ref_HostPtr () const |
size_t | get_HostLen () const |
bool | isHostLoopback () const |
bool | isHostPrivate () const |
bool | put_HostLoopback (sa_family_t nFamily=AF_UNSPEC) |
COMPARE_t | CompareHost (const cNetAddress &SocketAddr) const |
HRESULT | SetHostStr (const char *pszHost, bool bWait=false) |
HRESULT | SetHostStrFix (const char *pszAddr, bool bWait=false) |
cStringA | get_HostStr () const |
cNetHost4 | get_HostIp4 () const |
void | put_HostIp4 (in_addr nIP) |
cNetHost6 | get_HostIp6 () const |
void | put_HostIp6 (const in6_addr &addr) |
bool | SetHostData (sa_family_t nFamily, const void *pHostData, size_t nDataSize=sizeof(in_addr)) |
void | ResetHost () |
void | put_Addr (const cNetAddress &rAddr) |
bool | SetAddrData (const sockaddr *pSockAddr, socklen_t nSockAddrLen) |
cStringA | get_AddrStr () const |
HRESULT | put_AddrStr (const char *pszAddr, bool bWait=false) |
HRESULT | SerializeOutput (cStreamOutput &rout) |
HRESULT | SerializeInput (cStreamInput &file) |
UNITTEST_FRIEND (cNetAddress) | |
Static Public Member Functions | |
static char *GRAYCALL | FindPortExtPtr (const char *pszAddr) |
Protected Member Functions | |
const in_addr & | ref_HostIp4 () const |
in_addr & | ref_HostIp4 () |
const in6_addr & | ref_HostIp6 () const |
in6_addr & | ref_HostIp6 () |
Network Address = (Family + Host + Port) in generic format. Handles an address in any network family: IPv4/AF_INET or IPv6/AF_INET6 or other Similar to MFC CSocketAddr Based on SOCKADDR,SOCKADDR_IN,sockaddr,sockaddr_in
|
inlinenoexcept |
sin_family = AF_UNSPEC; // AF_INET, AF_INET6, etc sin_port = k_NET_PORT_INVALID; sin_addr.s_addr = INADDR_NONE;
|
inlinenoexcept |
Default to a local/loopback connection
|
inlinenoexcept |
IPv4
|
inline |
Set the address by string.
|
inline |
Set the address by string. + default port. string overrides the port.
|
inline |
COMPARE_t GrayLib::cNetAddress::CompareHost | ( | const cNetAddress & | SocketAddr | ) | const |
Just compare hosts. ignore ports. Might use get_HashCodeHost ??
|
static |
Get the separator for the address and the port.
|
inlinenoexcept |
get pointer to the low level SOCKADDR structure.
|
inlinenoexcept |
How much of the address is used? or what is the max size allowed to be used.
cStringA GrayLib::cNetAddress::get_AddrStr | ( | ) | const |
get Address as a string = "host:port" IP4 = "HTTP://1.2.3.4:80/" IP6 = "HTTP://[2001:0f68:0000:0000:0000:0000:1986:69af]:80/"
|
inlinenoexcept |
AF_UNSPEC, AF_INET, AF_INET6, etc
|
inlinenoexcept |
|
noexcept |
cNetHost4 GrayLib::cNetAddress::get_HostIp4 | ( | ) | const |
cNetHost6 GrayLib::cNetAddress::get_HostIp6 | ( | ) | const |
Network order bytes.
|
inline |
Does not include port.
|
inline |
Does not include port.
cStringA GrayLib::cNetAddress::get_HostStr | ( | ) | const |
|
inlinenoexcept |
Ports have 3 ranges, 1.defined, 2.private, 3.temporary.
cStringA GrayLib::cNetAddress::get_PortServiceName | ( | ) | const |
bool GrayLib::cNetAddress::isAddrValid | ( | ) | const |
Is this host address valid?
bool GrayLib::cNetAddress::isHostLoopback | ( | ) | const |
Is this just a loopback to myself?
bool GrayLib::cNetAddress::isHostPrivate | ( | ) | const |
Is this address a private LAN address (intra-net) vs. public Internet address ?
|
inline |
ASSUME all sa_family_t support ports. not just AF_INET.
|
inline |
|
inline |
|
inline |
HRESULT GrayLib::cNetAddress::put_AddrStr | ( | const char * | pszAddr, |
bool | bWait = false |
||
) |
Set address and port together from a string. leave port if not provided in string.
|
inline |
Just set host. Leave port unset.
|
inline |
Just set host. Leave port unset.
bool GrayLib::cNetAddress::put_HostLoopback | ( | sa_family_t | nFamily = AF_UNSPEC | ) |
Set to local loop-back Address. Leave Port.
|
inline |
ASSUME all sa_family_t support ports.
bool GrayLib::cNetAddress::put_PortServiceName | ( | const char * | pszPortServiceName | ) |
find the service name as the port number. (e.g. pszPort = "http","ftp",etc)
|
inlinenoexcept |
get const ref to the low level SOCKADDR structure. supports Windows vs. Unix prototype differences.
|
inlinenoexcept |
get ref to the low level SOCKADDR structure.
|
inlinenoexcept |
Berkley sockets functions can set the size this way.
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inline |
Does not include port.
|
inlinenoexcept |
|
inline |
clear address but keep the port. Reset just host (so it will re-resolve) but not the port.
HRESULT GrayLib::cNetAddress::SerializeInput | ( | cStreamInput & | file | ) |
HRESULT GrayLib::cNetAddress::SerializeOutput | ( | cStreamOutput & | rout | ) |
bool GrayLib::cNetAddress::SetAddrData | ( | const sockaddr * | pSockAddr, |
socklen_t | nSockAddrLen | ||
) |
set sockaddr directly. usually coming from some sort of hostname resolution. Similar to SetHostData. but from addrinfo May set port or leave it alone. like SetHostData() nSockAddrLen = sizeof(sockaddr)
bool GrayLib::cNetAddress::SetHostData | ( | sa_family_t | nFamily, |
const void * | pHostData, | ||
size_t | nDataSize = sizeof(in_addr) |
||
) |
set sockaddr directly. Set host address. NOT set port. like SetAddrData()
HRESULT GrayLib::cNetAddress::SetHostStr | ( | const char * | pszHost, |
bool | bWait = false |
||
) |
Set just the host. ASSUME NO :Port is here. resolve native address without blocking. Must block to lookup hostname.
HRESULT GrayLib::cNetAddress::SetHostStrFix | ( | const char * | pszAddr, |
bool | bWait = false |
||
) |
Strip the port from the address name.
GrayLib::cNetAddress::UNITTEST_FRIEND | ( | cNetAddress | ) |
sockaddr GrayLib::cNetAddress::m_SockAddr |
Address that is family independent. (interchangeable with sockaddr/SOCKADDR/SOCKADDR_IN. NO Port)
sockaddr_in GrayLib::cNetAddress::m_SockAddr4 |
Address is ipv4 = 16 bytes.
sockaddr_in6 GrayLib::cNetAddress::m_SockAddr6 |
Address is ipv6 = 28 bytes.