Adbase
Adinf C++ base library V2
adbase::InetAddress Class Reference

#include <InetAddress.hpp>

Public Member Functions

 InetAddress (uint16_t port=0, bool loopbackOnly=false)
 
 InetAddress (std::string ip, uint16_t port)
 Constructs an endpoint with given ip and port. More...
 
 InetAddress (const struct sockaddr_in &addr)
 Constructs an endpoint with given struct sockaddr_in Mostly used when accepting new connections. More...
 
std::string toIp () const
 
std::string toIpPort () const
 
uint16_t toPort () const
 
const struct sockaddr_in & getSockAddrInet () const
 
void setSockAddrInet (const struct sockaddr_in &addr)
 
uint32_t ipNetEndian () const
 
uint16_t portNetEndian () const
 

Static Public Member Functions

static bool resolve (const std::string &hostname, std::string &ip)
 resolve hostname to IP address, not changing port or sin_family return true on success. More...
 
static bool resolveAll (const std::string &hostname, std::vector< std::string > &ip)
 

Detailed Description

Definition at line 19 of file InetAddress.hpp.

Constructor & Destructor Documentation

adbase::InetAddress::InetAddress ( uint16_t  port = 0,
bool  loopbackOnly = false 
)
explicit
adbase::InetAddress::InetAddress ( std::string  ip,
uint16_t  port 
)

Constructs an endpoint with given ip and port.

ip should be "1.2.3.4"

Definition at line 32 of file InetAddress.cpp.

References adbase::sockets::fromIpPort().

adbase::InetAddress::InetAddress ( const struct sockaddr_in &  addr)
inline

Constructs an endpoint with given struct sockaddr_in Mostly used when accepting new connections.

Definition at line 29 of file InetAddress.hpp.

References toIp(), toIpPort(), and toPort().

Member Function Documentation

const struct sockaddr_in& adbase::InetAddress::getSockAddrInet ( ) const
inline

Definition at line 37 of file InetAddress.hpp.

Referenced by adbase::Socket::bindAddress(), and adbase::Connector::restart().

uint32_t adbase::InetAddress::ipNetEndian ( ) const
inline

Definition at line 45 of file InetAddress.hpp.

uint16_t adbase::InetAddress::portNetEndian ( ) const
inline

Definition at line 49 of file InetAddress.hpp.

References adbase::hostname(), resolve(), and resolveAll().

bool adbase::InetAddress::resolve ( const std::string &  hostname,
std::string &  ip 
)
static

resolve hostname to IP address, not changing port or sin_family return true on success.

thread safe

Definition at line 66 of file InetAddress.cpp.

References LOG_SYSERR.

Referenced by portNetEndian(), and adbase::Connector::restart().

bool adbase::InetAddress::resolveAll ( const std::string &  hostname,
std::vector< std::string > &  ip 
)
static

Definition at line 96 of file InetAddress.cpp.

References LOG_SYSERR.

Referenced by portNetEndian().

void adbase::InetAddress::setSockAddrInet ( const struct sockaddr_in &  addr)
inline

Definition at line 41 of file InetAddress.hpp.

Referenced by adbase::Socket::accept().

std::string adbase::InetAddress::toIp ( ) const

Definition at line 49 of file InetAddress.cpp.

References adbase::sockets::toIp().

Referenced by adbase::Connector::Connector(), and InetAddress().

std::string adbase::InetAddress::toIpPort ( ) const
uint16_t adbase::InetAddress::toPort ( ) const

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