coral
A C++ library for distributed co-simulation
|
An object which identifies an internet host or network interface as either an IPv4 address or a textual name. More...
#include "coral/net.hpp"
Public Member Functions | |
Address () CORAL_NOEXCEPT | |
Default constructor which sets the address to "*". | |
Address (const std::string &address) | |
Constructor which takes an address in string form. More... | |
Address (in_addr address) CORAL_NOEXCEPT | |
Constructor which takes an IP address as an in_addr. | |
bool | IsAnyAddress () const CORAL_NOEXCEPT |
Returns whether this address is the special "any address" value. | |
bool | IsName () const CORAL_NOEXCEPT |
Returns whether this address is a name (i.e., host or interface name) | |
std::string | ToString () const CORAL_NOEXCEPT |
Returns a string representation of the address. | |
in_addr | ToInAddr () const |
Returns the address as an in_addr object. More... | |
Friends | |
bool | operator== (const Address &, const Address &) |
Equality operator for coral::net::ip::Address . More... | |
An object which identifies an internet host or network interface as either an IPv4 address or a textual name.
If the address is specified as a string, it may either be an IPv4 address in dotted-decimal format, or, depending on the context in which the address is used, a host name or an (OS-defined) local network interface name.
The special name "*" may be used in certain contexts to refer to all available network interfaces, and corresponds to the POSIX/WinSock constant INADDR_ANY and the IPv4 address 0.0.0.0.
coral::net::ip::Address::Address | ( | const std::string & | address | ) |
Constructor which takes an address in string form.
The validity of the address is not checked, and no host name resolution or interface-IP lookup is performed.
std::invalid_argument | If address is empty. |
in_addr coral::net::ip::Address::ToInAddr | ( | ) | const |
Returns the address as an in_addr object.
If the address was specified as "*", this returns an in_addr
whose s_addr
member is equal to INADDR_ANY
. Otherwise, this function requires that the address was specified as an IPv4 address in the first place. No host name resolution or interface lookup is performed.
std::logic_error | If the address could not be converted. |
Equality operator for coral::net::ip::Address
.
This returns true
if and only if the addresses themselves match. No host name resolution or interface lookup is performed.