CUGL 2.5
Cornell University Game Library
|
#include <CUInetAddress.h>
Public Types | |
enum class | Type : int { INVALID = 0 , IPV4 = 1 , IPV6 = 2 , HOSTNAME = 3 } |
Public Member Functions | |
InetAddress () | |
InetAddress (uint16_t port) | |
InetAddress (const std::string address, uint16_t port=0) | |
InetAddress (const std::shared_ptr< JsonValue > &prefs) | |
InetAddress (const InetAddress &src)=default | |
InetAddress (InetAddress &&src)=default | |
~InetAddress () | |
InetAddress & | operator= (const InetAddress &src)=default |
InetAddress & | operator= (InetAddress &&src)=default |
InetAddress & | set (const InetAddress &src) |
InetAddress & | set (const std::shared_ptr< InetAddress > &src) |
virtual InetAddress & | set (const std::shared_ptr< JsonValue > &pref) |
virtual const std::string | toString () const |
Type | getType () const |
bool | isValid () const |
Public Attributes | |
std::string | address |
uint16_t | port |
This class represents an internet address
This class is effectively a simple struct. All attributes are publicly available and we do not use the standard CUGL shared pointer architecture. Internet addresses are designed to be use on the stack, though you can combine them with share pointers if you wish.
This class does have methods for validating an address, as well as determining its type (IPV4, IPV6 or Hostname). The latter is important for converting the address to a string, as IPV6 addresses must be inclosed in brackets when combined with the port. Because the attributes are publicly accessible, none of this information is cached. Instead, it is computed on demand as necessary.
|
strong |
This enum represents the interet address type.
This value allows us to have a single class that supports both IPV4 and IPV6 address values.
cugl::net::InetAddress::InetAddress | ( | ) |
Creates an internet address to refer to the localhost
The address will be the hostname "localhost". The port will be 0. The constructor does not perform any validation that the combined address port are reachable.
cugl::net::InetAddress::InetAddress | ( | uint16_t | port | ) |
Creates an internet address to refer to the localhost
The address will be the hostname "localhost". The constructor does not perform any validation that the combined address port are reachable.
port | The address port |
cugl::net::InetAddress::InetAddress | ( | const std::string | address, |
uint16_t | port = 0 |
||
) |
Creates an internet address for the given address.
The constructor does not perform any validation that the combined address and port are reachable.
address | The internet address |
port | The address port |
cugl::net::InetAddress::InetAddress | ( | const std::shared_ptr< JsonValue > & | prefs | ) |
Creates this internet address using a JSON entry.
The JSON value should be an object with at least two keys: "address" and "port". The "port" should be an integer.
prefs | The address settings |
|
default |
Creates a copy of the given internet address.
This copy constructor is provided so that internet addresses may be safely used on the stack, without the use of pointers.
src | The original internet address to copy |
|
default |
Creates a new internet address with the resources of the given one.
This move constructor is provided so that internet addresses may be used efficiently on the stack, without the use of pointers.
src | The original address contributing resources |
|
inline |
Deletes this internet address, disposing all resources
Type cugl::net::InetAddress::getType | ( | ) | const |
Returns the type of this address.
The method only checks the syntax of the address, and not whether the address is actually reachable. As the address attributes are publicly accessible, this value is not cached, but is instead recomputed each time this method is called.
|
inline |
Returns the true if this address is syntactically valid.
The method only checks the syntax of the address, and not whether the address is actually reachable. As the address attributes are publicly accessible, this value is not cached, but is instead recomputed each time this method is called.
|
default |
Assigns this address to be a copy of the given internet address.
src | The address to copy |
|
default |
Assigns this address to have the resources of the given internet address.
src | The address to take resources from |
InetAddress & cugl::net::InetAddress::set | ( | const InetAddress & | src | ) |
Assigns this address to be a copy of the given internet address.
src | The address to copy |
InetAddress & cugl::net::InetAddress::set | ( | const std::shared_ptr< InetAddress > & | src | ) |
Assigns this address to be a copy of the given internet address.
src | The address to copy |
|
virtual |
Assigns this address according to the given JSON object
The JSON value should be an object with at least two keys: "address" and "port". The "port" should be an integer.
pref | The address settings |
Reimplemented in cugl::net::ICEAddress.
|
virtual |
Returns a string representation of this address.
The string with combine the address string with the port, separated by a colon. No attempt is made to normalize IPV4 or IPV6 addresses.
Reimplemented in cugl::net::ICEAddress.
std::string cugl::net::InetAddress::address |
The internet address
uint16_t cugl::net::InetAddress::port |
The address port