coral
A C++ library for distributed co-simulation
Public Member Functions | Friends | List of all members
coral::net::ip::Address Class Reference

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

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.

Exceptions
std::invalid_argumentIf address is empty.

Member Function Documentation

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.

Exceptions
std::logic_errorIf the address could not be converted.

Friends And Related Function Documentation

bool operator== ( const Address ,
const Address  
)
friend

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.


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