Adbase
Adinf C++ base library V2
|
#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) |
Definition at line 19 of file InetAddress.hpp.
|
explicit |
Definition at line 21 of file InetAddress.cpp.
References adbase::hostToNetwork16(), adbase::hostToNetwork32(), and adbase::kInaddrAny.
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().
|
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().
|
inline |
Definition at line 37 of file InetAddress.hpp.
Referenced by adbase::Socket::bindAddress(), and adbase::Connector::restart().
|
inline |
Definition at line 45 of file InetAddress.hpp.
|
inline |
Definition at line 49 of file InetAddress.hpp.
References adbase::hostname(), resolve(), and resolveAll().
|
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().
|
static |
Definition at line 96 of file InetAddress.cpp.
References LOG_SYSERR.
Referenced by portNetEndian().
|
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 |
Definition at line 40 of file InetAddress.cpp.
References adbase::sockets::toIpPort().
Referenced by adbase::Acceptor::acceptHandler(), adbase::Acceptor::Acceptor(), adbase::Connector::handleError(), and InetAddress().
uint16_t adbase::InetAddress::toPort | ( | ) | const |
Definition at line 58 of file InetAddress.cpp.
References adbase::networkToHost16().
Referenced by adbase::Connector::Connector(), InetAddress(), and adbase::TcpServer::newConnection().