25 #ifndef NRG_NETADDRESS_H
26 #define NRG_NETADDRESS_H
38 NetAddress(
const char* name,
const char* port);
53 bool resolve(
const char* name,
const char* port);
59 const char*
getIP()
const;
68 const struct sockaddr*
toSockAddr(socklen_t& out_size)
const;
77 mutable char text[INET6_ADDRSTRLEN];
78 struct sockaddr_storage addr;
bool isValid() const
Queries whether or not the contained address is valid.
const char * getIP() const
Returns the contained IP address as a string, if no address is contained it returns "" - do not free...
NetAddress()
Default constructor.
friend bool operator<(const NetAddress &a, const NetAddress &b)
Less-than operator for total-ordered containers like std::map.
friend bool operator==(const NetAddress &a, const NetAddress &b)
Equality operator.
int getFamily() const
Returns the family of the contained address, (AF_INET, AF_INET6 or AF_UNSPEC)
const struct sockaddr * toSockAddr(socklen_t &out_size) const
Returns a sockaddr* representation of the NetAddress to be used with POSIX socket functions - do not ...
bool resolve(const char *name, const char *port)
Resolve the given IP/Hostname and Port/Service into an address, returning true on success...
Common defines and includes used by all the other nrg header files.
friend bool operator!=(const NetAddress &a, const NetAddress &b)
Unequality operator.
Class to wrap the various POSIX sockaddrs and resolve hostnames.
Definition: nrg_netaddress.h:32
uint16_t getPort() const
Returns the contained address' port as a short in host byte order.