class RNET::Address
This class defines a network address. More...
#include <RNETAddress.h>
Inherits: Object.
Public functions:
Address ( ) | |
Address ( const RED::String & iString ) | |
Address ( unsigned int iIPv4, unsigned short iPort = 0 ) | |
~Address ( ) | |
unsigned int | IPv4 ( ) const |
bool | IsValid ( ) const |
bool | IsWeb ( ) const |
bool | operator!= ( const Address & other ) const |
bool | operator< ( const Address & other ) const |
bool | operator== ( const Address & other ) const |
unsigned short | Port ( ) const |
void | Reset ( ) |
const RED::String & | ToString ( ) const |
void | ToString ( RED::String & oAddress, RED::String & oPort ) const |
Public static functions:
static RNET::Address | Broadcast ( unsigned int iPort ) |
static RNET::Address | Host ( unsigned short iPort ) |
static RNET::Address | LocalHost ( unsigned short iPort ) |
Protected variables:
unsigned int | _ip [4] |
bool | _is_web |
unsigned short | _port |
RED::String | _string |
RED::String | _string_address |
RED::String | _string_port |
bool | _valid |
Detailed description:
This class defines a network address.
A network address can be either a single IP address (only v4 is supported right now) or an IP address and a port.
This class offers several helpers to access to the address under various forms.
Note:
The numerical values are always returned in network byte order! The setting of numerical values can be in hardware or network byte order depending on the method called; check the corresponding documentation!
Functions documentation
public RNET::Address::Address | ( | ) |
Default constructor.
While no address has been set manually, this object stays invalid.
public RNET::Address::Address | ( | const RED::String & | iString | ) |
Constructs an address from a string.
The string must follow:
a.b.c.dor a.b.c.d:port
where a.b.c.d is a valid IP v4 address and port is an optional port value.
Parameters:
iString | the address as a string. |
public RNET::Address::Address | ( | unsigned int | iIPv4, |
unsigned short | iPort = 0 | ||
) |
Constructs an address from an IP v4 address in network byte order.
Parameters:
iIPv4 | IP v4 address in network byte order. |
iPort | optional port in network byte order. |
public RNET::Address::~Address | ( | ) |
Destructor.
public unsigned int RNET::Address::IPv4 | ( | ) const |
Returns:
public bool RNET::Address::IsValid | ( | ) const |
Returns:
false otherwise.
public bool RNET::Address::IsWeb | ( | ) const |
Returns:
public bool RNET::Address::operator!= | ( | const Address & | other | ) const |
Inequality comparison operator.
public bool RNET::Address::operator< | ( | const Address & | other | ) const |
Less than comparison operator.
public bool RNET::Address::operator== | ( | const Address & | other | ) const |
Equality comparison operator.
public unsigned short RNET::Address::Port | ( | ) const |
Returns:
public void RNET::Address::Reset | ( | ) |
Resets the address content and set it back to invalid.
public const RED::String & RNET::Address::ToString | ( | ) const |
Returns a string version of the address.
If the address contains a port, the output will have the following format: a.b.c.d:port, otherwise, it will look like: a.b.c.d.
Returns:
public void RNET::Address::ToString | ( | RED::String & | oAddress, |
RED::String & | oPort | ||
) | const |
Returns both address and port strings from the address.
Parameters:
oAddress | reference to the returned IP string. |
oPort | reference to the returned port string. |
public static RNET::Address RNET::Address::Broadcast | ( | unsigned int | iPort | ) |
Returns the broadcast address including the given port.
Parameters:
iPort | the port to use in hardware byte order (not in network byte order!). |
Returns:
public static RNET::Address RNET::Address::Host | ( | unsigned short | iPort | ) |
Returns the network address of the host machine including the given port.
Parameters:
iPort | the port to use in hardware byte order (not in network byte order!). |
Returns:
public static RNET::Address RNET::Address::LocalHost | ( | unsigned short | iPort | ) |
Returns the network address of the loopback interface (most of the time 127.0.0.1) including the given port.
Parameters:
iPort | the port to use in hardware byte order (not in network byte order!). |
Returns:
Variables documentation
IP address (v4 only).
true if the address was created with a WWW URL, false otherwise.
optional port.
string version of the full IP address (including port).
string version of the IP address only.
string version of the port only.
true if the address is valid, false otherwise.