Address
Functions
void |
|
bool |
|
unsigned int |
|
unsigned short |
|
bool |
|
const String & |
|
void |
|
bool |
|
bool |
|
bool |
|
Detailed Description
-
class Address : public RED::Object
This class defines a network address.
@related class RNET::System
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!
Note
The setting of numerical values can be in hardware or network byte order depending on the method called; check the corresponding documentation!
Public Functions
-
Address()
Default constructor.
While no address has been set manually, this object stays invalid.
-
Address(const RED::String &iString)
Constructs an address from a string.
The string must follow:
a.b.c.d or 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.
-
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.
-
~Address()
Destructor.
-
void Reset()
Resets the address content and set it back to invalid.
-
inline bool IsValid() const
- Returns
true if a valid IP address has been set,false otherwise.
-
inline unsigned int IPv4() const
- Returns
the address in IP v4 format in network byte order.
-
inline unsigned short Port() const
- Returns
the optional port of the address in network byte order.
-
inline bool IsWeb() const
- Returns
true if the address starts with “www.”, false otherwise.
-
inline const RED::String &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
a string version of the address.
Public Static Functions
-
static 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
the network address of the local machine including the given port.
-
Address()