Wrapper of sockaddr_in. This is an POD interface class.
More...
#include <trantor/net/InetAddress.h>
|
| | InetAddress (uint16_t port=0, bool loopbackOnly=false, bool ipv6=false) |
| | Constructs an endpoint with given port number. Mostly used in TcpServer listening.
|
| | InetAddress (const std::string &ip, uint16_t port, bool ipv6=false) |
| | Constructs an endpoint with given ip and port.
|
| | InetAddress (const struct sockaddr_in &addr) |
| | Constructs an endpoint with given struct sockaddr_in. Mostly used when accepting new connections.
|
| | InetAddress (const struct sockaddr_in6 &addr) |
| | Constructs an IPv6 endpoint with given struct sockaddr_in6. Mostly used when accepting new connections.
|
| sa_family_t | family () const |
| | Return the sin_family of the endpoint.
|
| std::string | toIp () const |
| | Return the IP string of the endpoint.
|
| std::string | toIpPort () const |
| | Return the IP and port string of the endpoint.
|
| std::string | toIpNetEndian () const |
| | Return the IP bytes of the endpoint in net endian byte order.
|
| std::string | toIpPortNetEndian () const |
| | Return the IP and port bytes of the endpoint in net endian byte order.
|
| uint16_t | toPort () const |
| | Return the port number of the endpoint.
|
| bool | isIpV6 () const |
| | Check if the endpoint is IPv4 or IPv6.
|
| bool | isIntranetIp () const |
| | Return true if the endpoint is an intranet endpoint.
|
| bool | isLoopbackIp () const |
| | Return true if the endpoint is a loopback endpoint.
|
| const struct sockaddr * | getSockAddr () const |
| | Get the pointer to the sockaddr struct.
|
| void | setSockAddrInet6 (const struct sockaddr_in6 &addr6) |
| | Set the sockaddr_in6 struct in the endpoint.
|
| uint32_t | ipNetEndian () const |
| | Return the integer value of the IP(v4) in net endian byte order.
|
| const uint32_t * | ip6NetEndian () const |
| | Return the pointer to the integer value of the IP(v6) in net endian byte order.
|
| uint16_t | portNetEndian () const |
| | Return the port number in net endian byte order.
|
| void | setPortNetEndian (uint16_t port) |
| | Set the port number in net endian byte order.
|
|
bool | isUnspecified () const |
| | Return true if the address is not initialized.
|
Wrapper of sockaddr_in. This is an POD interface class.
◆ InetAddress() [1/4]
| trantor::InetAddress::InetAddress |
( |
uint16_t | port = 0, |
|
|
bool | loopbackOnly = false, |
|
|
bool | ipv6 = false ) |
Constructs an endpoint with given port number. Mostly used in TcpServer listening.
- Parameters
-
◆ InetAddress() [2/4]
| trantor::InetAddress::InetAddress |
( |
const std::string & | ip, |
|
|
uint16_t | port, |
|
|
bool | ipv6 = false ) |
Constructs an endpoint with given ip and port.
- Parameters
-
| ip | A IPv4 or IPv6 address. |
| port | |
| ipv6 | |
◆ InetAddress() [3/4]
| trantor::InetAddress::InetAddress |
( |
const struct sockaddr_in & | addr | ) |
|
|
inlineexplicit |
Constructs an endpoint with given struct sockaddr_in. Mostly used when accepting new connections.
- Parameters
-
◆ InetAddress() [4/4]
| trantor::InetAddress::InetAddress |
( |
const struct sockaddr_in6 & | addr | ) |
|
|
inlineexplicit |
Constructs an IPv6 endpoint with given struct sockaddr_in6. Mostly used when accepting new connections.
- Parameters
-
◆ family()
| sa_family_t trantor::InetAddress::family |
( |
| ) |
const |
|
inline |
Return the sin_family of the endpoint.
- Returns
- sa_family_t
◆ getSockAddr()
| const struct sockaddr * trantor::InetAddress::getSockAddr |
( |
| ) |
const |
|
inline |
Get the pointer to the sockaddr struct.
- Returns
- const struct sockaddr*
◆ ip6NetEndian()
| const uint32_t * trantor::InetAddress::ip6NetEndian |
( |
| ) |
const |
Return the pointer to the integer value of the IP(v6) in net endian byte order.
- Returns
- const uint32_t*
◆ ipNetEndian()
| uint32_t trantor::InetAddress::ipNetEndian |
( |
| ) |
const |
Return the integer value of the IP(v4) in net endian byte order.
- Returns
- uint32_t
◆ isIntranetIp()
| bool trantor::InetAddress::isIntranetIp |
( |
| ) |
const |
Return true if the endpoint is an intranet endpoint.
- Returns
- true
-
false
◆ isIpV6()
| bool trantor::InetAddress::isIpV6 |
( |
| ) |
const |
|
inline |
Check if the endpoint is IPv4 or IPv6.
- Returns
- true
-
false
◆ isLoopbackIp()
| bool trantor::InetAddress::isLoopbackIp |
( |
| ) |
const |
Return true if the endpoint is a loopback endpoint.
- Returns
- true
-
false
◆ portNetEndian()
| uint16_t trantor::InetAddress::portNetEndian |
( |
| ) |
const |
|
inline |
Return the port number in net endian byte order.
- Returns
- uint16_t
◆ setPortNetEndian()
| void trantor::InetAddress::setPortNetEndian |
( |
uint16_t | port | ) |
|
|
inline |
Set the port number in net endian byte order.
- Parameters
-
◆ setSockAddrInet6()
| void trantor::InetAddress::setSockAddrInet6 |
( |
const struct sockaddr_in6 & | addr6 | ) |
|
|
inline |
Set the sockaddr_in6 struct in the endpoint.
- Parameters
-
◆ toIp()
| std::string trantor::InetAddress::toIp |
( |
| ) |
const |
Return the IP string of the endpoint.
- Returns
- std::string
◆ toIpNetEndian()
| std::string trantor::InetAddress::toIpNetEndian |
( |
| ) |
const |
Return the IP bytes of the endpoint in net endian byte order.
- Returns
- std::string
◆ toIpPort()
| std::string trantor::InetAddress::toIpPort |
( |
| ) |
const |
Return the IP and port string of the endpoint.
- Returns
- std::string
◆ toIpPortNetEndian()
| std::string trantor::InetAddress::toIpPortNetEndian |
( |
| ) |
const |
Return the IP and port bytes of the endpoint in net endian byte order.
- Returns
- std::string
◆ toPort()
| uint16_t trantor::InetAddress::toPort |
( |
| ) |
const |
Return the port number of the endpoint.
- Returns
- uint16_t
The documentation for this class was generated from the following file: