Nebula
|
#include <win32ipaddress.h>
Represents an IP address, consisting of a IPv4 host address and a port number.
Performs automatic name lookup on the host name. Can extract address information from an URI and
automatically converts host names to addresses, and offers the special hostnames "localhost", "any", "broadcast", "self" and "inetself" where:
Public Member Functions | |
Win32IpAddress () | |
default constructor | |
Win32IpAddress (const Win32IpAddress &rhs) | |
copy constructor | |
Win32IpAddress (const IO::URI &uri) | |
construct from URI | |
Win32IpAddress (const Util::String &hostName, ushort portNumber) | |
construct from host name and port number | |
bool | operator== (const Win32IpAddress &rhs) const |
equality operator | |
bool | operator< (const Win32IpAddress &rhs) const |
less-then operator | |
bool | operator> (const Win32IpAddress &rhs) const |
greater-then operator | |
void | ExtractFromUri (const IO::URI &uri) |
extract host name and port number from URI | |
void | SetHostName (const Util::String &hostName) |
set host name | |
const Util::String & | GetHostName () const |
get host name | |
void | SetPort (ushort port) |
set port number | |
ushort | GetPort () const |
get port number | |
const Util::String & | GetHostAddr () const |
get the ip address resulting from the host name as string | |
Private Member Functions | |
Win32IpAddress (const sockaddr_in &addr) | |
construct from sockaddr_in struct | |
void | SetSockAddr (const sockaddr_in &addr) |
set sockaddr_in directly | |
const sockaddr_in & | GetSockAddr () const |
get sockaddr_in field | |
Static Private Member Functions | |
static bool | GetHostByName (const Util::String &hostName, in_addr &outAddr) |
perform address resolution, understands special host names | |
static bool | IsInetAddr (const in_addr *addr) |
return true if an address is an internet address (not class A,B,C) | |
Private Attributes | |
Util::String | hostName |
Util::String | addrAsString |
sockaddr_in | addr |
Friends | |
class | Win32Socket |
Win32::Win32IpAddress::Win32IpAddress | ( | ) |
default constructor
Win32::Win32IpAddress::Win32IpAddress | ( | const Win32IpAddress & | rhs | ) |
copy constructor
Win32::Win32IpAddress::Win32IpAddress | ( | const IO::URI & | uri | ) |
construct from URI
Win32::Win32IpAddress::Win32IpAddress | ( | const Util::String & | hostName, |
ushort | portNumber ) |
construct from host name and port number
|
private |
construct from sockaddr_in struct
void Win32::Win32IpAddress::ExtractFromUri | ( | const IO::URI & | uri | ) |
extract host name and port number from URI
Extract the host name and optionally the port number from the provided URI.
If no port number is set in the URI, the current port number will be left as is. If the host name is empty, it will be set to "localhost".
const String & Win32::Win32IpAddress::GetHostAddr | ( | ) | const |
get the ip address resulting from the host name as string
Return the in address as string.
|
staticprivate |
perform address resolution, understands special host names
This resolves a host name into a IPv4 ip address.
The ip address is returned in network byte order in the hostAddress argument. The return value indicates whether the operation was successful. The following special hostnames can be defined:
An empty host name is invalid. A hostname can also be an address string of the form xxx.yyy.zzz.www.
NOTE: resolving host names and host addresses is not supported on the Xbox360, this basically means that an Xbox360 devkit can function as a server, but not as a client (this is fine for most debugging purposes).
const String & Win32::Win32IpAddress::GetHostName | ( | ) | const |
get host name
Get the host name.
ushort Win32::Win32IpAddress::GetPort | ( | ) | const |
get port number
Get the port number in host byte order.
|
private |
get sockaddr_in field
Get the sockaddr_in struct, which has either been set directly with SetSockAddr() or indirectly through host name, port number or from an URI.
|
staticprivate |
return true if an address is an internet address (not class A,B,C)
This method checks if the provided address is an "internet" address, not a LAN address (not a class A, B or C network address).
|
inline |
less-then operator
|
inline |
equality operator
|
inline |
greater-then operator
void Win32::Win32IpAddress::SetHostName | ( | const Util::String & | hostName | ) |
set host name
Set the host name, and immediately convert it to an ip address.
This accepts the special hostnames "any", "broadcast", "localhost", "self" and "inetself". The result ip address can be returned in string form with the method GetAddrAsString().
void Win32::Win32IpAddress::SetPort | ( | ushort | port | ) |
set port number
Set the port number.
Will be translated to network byte order internally.
|
private |
set sockaddr_in directly
Set the address directly from a sockaddr_in struct.
This will set the host name to the string representation of the host address.
|
friend |
|
private |
|
private |
|
private |