|
blocxx
|
#include <SocketAddress.hpp>
Public Types | |
| enum | AddressType { UNSET , INET , UDS } |
Public Member Functions | |
| AddressType | getType () const |
| UInt16 | getPort () const |
| Get the port associated with the address. | |
| ~SocketAddress () | |
| const String | getName () const |
| Returns the hostname (FQDN) of the address. | |
| const String | getAddress () const |
| Returns the IP address of the host. | |
| const SocketAddress_t * | getNativeForm () const |
| size_t | getNativeFormSize () const |
| const InetSocketAddress_t * | getInetAddress () const |
| Get a pointer to the InetSocketAddress_t precondition: getType() == INET. | |
| const UnixSocketAddress_t * | getUnixAddress () const |
| Get a pointer to the UnixSocketAddress_t precondition: getType() == UDS. | |
| void | assignFromNativeForm (const UnixSocketAddress_t *address, size_t len) |
| const String | toString () const |
| Returns the IP address and the port with a colon in between. | |
| void | assignFromNativeForm (const InetSocketAddress_t *address, size_t len) |
| SocketAddress () | |
Static Public Member Functions | |
| static SocketAddress | getByName (const String &host, unsigned short port=0) |
| Do a DNS lookup on a hostname and return an SocketAddress for that host. | |
| static SocketAddress | getAnyLocalHost (UInt16 port=0) |
| Do a DNS lookup on a hostname and return a list of all addresses that map to that hostname. | |
| static SocketAddress | allocEmptyAddress (AddressType type) |
| Allocate an empty SocketAddress. | |
| static SocketAddress | getUDS (const String &filename) |
Static Public Attributes | |
| static const char *const | ALL_LOCAL_ADDRESSES = "0.0.0.0" |
Private Member Functions | |
| SocketAddress (const InetSocketAddress_t &nativeForm) | |
| SocketAddress (const UnixSocketAddress_t &nativeForm) | |
Static Private Member Functions | |
| static SocketAddress | getFromNativeForm (const InetAddress_t &nativeForm, UInt16 nativePort, const String &hostname) |
| static SocketAddress | getFromNativeForm (const InetSocketAddress_t &nativeForm) |
| static SocketAddress | getFromNativeForm (const UnixSocketAddress_t &nativeForm) |
Private Attributes | |
| String | m_name |
| String | m_address |
| size_t | m_nativeSize |
| InetSocketAddress_t | m_inetNativeAddress |
| UnixSocketAddress_t | m_UDSNativeAddress |
| AddressType | m_type |
Definition at line 55 of file SocketAddress.hpp.
| Enumerator | |
|---|---|
| UNSET | |
| INET | |
| UDS | |
Definition at line 60 of file SocketAddress.hpp.
|
inline |
Definition at line 103 of file SocketAddress.hpp.
| BLOCXX_NAMESPACE::SocketAddress::SocketAddress | ( | ) |
Definition at line 142 of file SocketAddress.cpp.
Referenced by allocEmptyAddress(), getByName(), getFromNativeForm(), getFromNativeForm(), and getFromNativeForm().
|
private |
Definition at line 401 of file SocketAddress.cpp.
References assignFromNativeForm(), and BLOCXX_NAMESPACE::operator==().
|
private |
Definition at line 393 of file SocketAddress.cpp.
References assignFromNativeForm(), and BLOCXX_NAMESPACE::operator==().
|
static |
Allocate an empty SocketAddress.
Definition at line 423 of file SocketAddress.cpp.
References BLOCXX_THROW, getFromNativeForm(), INET, BLOCXX_NAMESPACE::operator==(), SocketAddress(), and UDS.
Referenced by BLOCXX_NAMESPACE::ServerSocketImpl::doListen().
| void BLOCXX_NAMESPACE::SocketAddress::assignFromNativeForm | ( | const InetSocketAddress_t * | address, |
| size_t | len ) |
Definition at line 338 of file SocketAddress.cpp.
References INET, m_address, m_inetNativeAddress, m_nativeSize, m_type, and BLOCXX_NAMESPACE::operator==().
| void BLOCXX_NAMESPACE::SocketAddress::assignFromNativeForm | ( | const UnixSocketAddress_t * | address, |
| size_t | len ) |
Definition at line 361 of file SocketAddress.cpp.
References m_address, m_name, m_nativeSize, m_type, m_UDSNativeAddress, BLOCXX_NAMESPACE::operator==(), and UDS.
Referenced by BLOCXX_NAMESPACE::ServerSocketImpl::fillAddrParms(), BLOCXX_NAMESPACE::SocketBaseImpl::fillInetAddrParms(), BLOCXX_NAMESPACE::SocketBaseImpl::fillUnixAddrParms(), SocketAddress(), and SocketAddress().
Returns the IP address of the host.
Definition at line 413 of file SocketAddress.cpp.
References m_address.
Referenced by toString().
|
static |
Do a DNS lookup on a hostname and return a list of all addresses that map to that hostname.
| host | The hostname |
| port | The port |
| port | The port |
Definition at line 286 of file SocketAddress.cpp.
References getFromNativeForm(), BLOCXX_NAMESPACE::gethostbynameMutex, BLOCXX_NAMESPACE::hton32(), BLOCXX_NAMESPACE::String::npos, and BLOCXX_NAMESPACE::operator==().
|
static |
Do a DNS lookup on a hostname and return an SocketAddress for that host.
| host | The hostname |
| port | The port |
| UnknownHostException |
Definition at line 154 of file SocketAddress.cpp.
References BLOCXX_THROW, getFromNativeForm(), BLOCXX_NAMESPACE::gethostbynameMutex, INET, BLOCXX_NAMESPACE::operator==(), and SocketAddress().
Referenced by BLOCXX_NAMESPACE::ServerSocketImpl::doListenIPv4().
|
staticprivate |
Definition at line 237 of file SocketAddress.cpp.
References BLOCXX_NAMESPACE::hton16(), INET, BLOCXX_NAMESPACE::operator==(), and SocketAddress().
Referenced by allocEmptyAddress(), getAnyLocalHost(), and getByName().
|
staticprivate |
Definition at line 219 of file SocketAddress.cpp.
References BLOCXX_NAMESPACE::operator==(), and SocketAddress().
|
staticprivate |
Definition at line 228 of file SocketAddress.cpp.
References BLOCXX_NAMESPACE::operator==(), and SocketAddress().
| const InetSocketAddress_t * BLOCXX_NAMESPACE::SocketAddress::getInetAddress | ( | ) | const |
Get a pointer to the InetSocketAddress_t precondition: getType() == INET.
Definition at line 269 of file SocketAddress.cpp.
References m_inetNativeAddress.
Returns the hostname (FQDN) of the address.
Definition at line 408 of file SocketAddress.cpp.
References m_name.
| const SocketAddress_t * BLOCXX_NAMESPACE::SocketAddress::getNativeForm | ( | ) | const |
Definition at line 251 of file SocketAddress.cpp.
References INET, m_inetNativeAddress, m_type, m_UDSNativeAddress, BLOCXX_NAMESPACE::operator==(), and UDS.
Referenced by BLOCXX_NAMESPACE::ServerSocketImpl::doListenUDS().
| size_t BLOCXX_NAMESPACE::SocketAddress::getNativeFormSize | ( | ) | const |
Definition at line 418 of file SocketAddress.cpp.
References m_nativeSize.
Referenced by BLOCXX_NAMESPACE::ServerSocketImpl::doListenUDS().
| UInt16 BLOCXX_NAMESPACE::SocketAddress::getPort | ( | ) | const |
Get the port associated with the address.
Definition at line 373 of file SocketAddress.cpp.
References BLOCXX_ASSERT, INET, m_inetNativeAddress, m_type, BLOCXX_NAMESPACE::ntoh16(), and BLOCXX_NAMESPACE::operator==().
Referenced by toString().
|
inline |
Definition at line 66 of file SocketAddress.hpp.
Referenced by BLOCXX_NAMESPACE::ServerSocketImpl::accept(), BLOCXX_NAMESPACE::ServerSocketImpl::close(), and BLOCXX_NAMESPACE::ServerSocketImpl::fillAddrParms().
|
static |
Definition at line 102 of file SocketAddress.cpp.
References BLOCXX_THROW, BLOCXX_NAMESPACE::String::c_str(), BLOCXX_NAMESPACE::String::length(), m_type, BLOCXX_NAMESPACE::operator==(), and UDS.
Referenced by BLOCXX_NAMESPACE::ServerSocketImpl::doListenUDS().
| const UnixSocketAddress_t * BLOCXX_NAMESPACE::SocketAddress::getUnixAddress | ( | ) | const |
Get a pointer to the UnixSocketAddress_t precondition: getType() == UDS.
Definition at line 278 of file SocketAddress.cpp.
References m_UDSNativeAddress.
Returns the IP address and the port with a colon in between.
Definition at line 446 of file SocketAddress.cpp.
References BLOCXX_ASSERT, getAddress(), getPort(), INET, m_name, m_type, BLOCXX_NAMESPACE::operator==(), and UNSET.
Referenced by BLOCXX_NAMESPACE::ServerSocketImpl::close().
Definition at line 58 of file SocketAddress.hpp.
Referenced by BLOCXX_NAMESPACE::ServerSocketImpl::doListenIPv4().
|
private |
Definition at line 156 of file SocketAddress.hpp.
Referenced by assignFromNativeForm(), assignFromNativeForm(), and getAddress().
|
private |
Definition at line 159 of file SocketAddress.hpp.
Referenced by assignFromNativeForm(), getInetAddress(), getNativeForm(), and getPort().
|
private |
Definition at line 155 of file SocketAddress.hpp.
Referenced by assignFromNativeForm(), getName(), and toString().
|
private |
Definition at line 157 of file SocketAddress.hpp.
Referenced by assignFromNativeForm(), assignFromNativeForm(), and getNativeFormSize().
|
private |
Definition at line 165 of file SocketAddress.hpp.
Referenced by assignFromNativeForm(), assignFromNativeForm(), getNativeForm(), getPort(), getUDS(), and toString().
|
private |
Definition at line 162 of file SocketAddress.hpp.
Referenced by assignFromNativeForm(), getNativeForm(), and getUnixAddress().