Qyoto  4.0.5
Qyoto is a C# language binding for Qt
 All Classes Namespaces Functions Variables Typedefs Enumerations Properties
QtNetwork.QHostAddress Class Reference

The QHostAddress class provides an IP address. More...

Inheritance diagram for QtNetwork.QHostAddress:
Collaboration diagram for QtNetwork.QHostAddress:

Public Types

enum  SpecialAddress {
  Any = 4, AnyIPv6 = 5, Broadcast = 1, LocalHost = 2,
  LocalHostIPv6 = 3, Null = 0
}
 

Public Member Functions

override bool Equals (object o)
 
override int GetHashCode ()
 
 QHostAddress ()
 
 
 QHostAddress (QIPv6Address ip6Addr)
 
 
 QHostAddress (QHostAddress copy)
 
 
 QHostAddress (uint ip4Addr)
 
 
 QHostAddress (Pointer< byte > ip6Addr)
 
 
 QHostAddress (string address)
 
 
 QHostAddress (QHostAddress.SpecialAddress address)
 
 
virtual void CreateProxy ()
 
new void Clear ()
 
 
new bool IsInSubnet (QHostAddress subnet, int netmask)
 
 
new bool IsInSubnet (QPair< QHostAddress, System.Int32 > subnet)
 
 
new bool IsNull ()
 
 
new
QAbstractSocket.NetworkLayerProtocol 
Protocol ()
 
 
new void SetAddress (QIPv6Address ip6Addr)
 
 
new void SetAddress (uint ip4Addr)
 
 
new void SetAddress (Pointer< byte > ip6Addr)
 
 
new bool SetAddress (string address)
 
 
new uint ToIPv4Address ()
 
 
new QIPv6Address ToIPv6Address ()
 
 
override string ToString ()
 
 
new void Dispose ()
 

Static Public Member Functions

static bool operator!= (QHostAddress arg1, QHostAddress arg2)
 
 
static bool operator!= (QHostAddress arg1, QHostAddress.SpecialAddress arg2)
 
 
static bool operator== (QHostAddress arg1, QHostAddress arg2)
 
 
static bool operator== (QHostAddress arg1, QHostAddress.SpecialAddress arg2)
 
 
static QPair< QHostAddress,
System.Int32 > 
ParseSubnet (string subnet)
 
 

Protected Member Functions

 QHostAddress (System.Type dummy)
 

Protected Attributes

SmokeInvocation interceptor
 

Properties

new string ScopeId [get, set]
 
 
virtual System.IntPtr SmokeObject [get, set]
 

Detailed Description

The QHostAddress class provides an IP address.

This class holds an IPv4 or IPv6 address in a platform- and protocol-independent manner.

QHostAddress is normally used with the QTcpSocket, QTcpServer, and QUdpSocket to connect to a host or to set up a server.

A host address is set with setAddress(), and retrieved with toIPv4Address(), toIPv6Address(), or toString(). You can check the type with protocol().

Note: Please note that QHostAddress does not do DNS lookups. QHostInfo is needed for that.

The class also supports common predefined addresses: Null, LocalHost, LocalHostIPv6, Broadcast, and Any.

See also QHostInfo, QTcpSocket, QTcpServer, and QUdpSocket.

Member Enumeration Documentation

Enumerator:
Any 

The IPv4 any-address. Equivalent to QHostAddress("0.0.0.0").

AnyIPv6 

The IPv6 any-address. Equivalent to QHostAddress("::").

Broadcast 

The IPv4 broadcast address. Equivalent to QHostAddress("255.255.255.255").

LocalHost 

The IPv4 localhost address. Equivalent to QHostAddress("127.0.0.1").

LocalHostIPv6 

The IPv6 localhost address. Equivalent to QHostAddress("::1").

Null 

The null address object. Equivalent to QHostAddress().

Constructor & Destructor Documentation

QtNetwork.QHostAddress.QHostAddress ( System.Type  dummy)
protected
QtNetwork.QHostAddress.QHostAddress ( )

Constructs a host address object with the IP address 0.0.0.0.

See also clear().

QtNetwork.QHostAddress.QHostAddress ( QIPv6Address  ip6Addr)

Constructs a host address object with the IP address 0.0.0.0.

See also clear().

QtNetwork.QHostAddress.QHostAddress ( QHostAddress  copy)

Constructs a copy of the given address.

QtNetwork.QHostAddress.QHostAddress ( uint  ip4Addr)

Constructs a host address object with the IP address 0.0.0.0.

See also clear().

QtNetwork.QHostAddress.QHostAddress ( Pointer< byte >  ip6Addr)

Constructs a host address object with the IP address 0.0.0.0.

See also clear().

QtNetwork.QHostAddress.QHostAddress ( string  address)

Constructs an IPv4 or IPv6 address based on the string address (e.g., "127.0.0.1").

See also setAddress().

QtNetwork.QHostAddress.QHostAddress ( QHostAddress.SpecialAddress  address)

Constructs a QHostAddress object for address.

Member Function Documentation

new void QtNetwork.QHostAddress.Clear ( )

Sets the host address to 0.0.0.0.

virtual void QtNetwork.QHostAddress.CreateProxy ( )
virtual
new void QtNetwork.QHostAddress.Dispose ( )
override bool QtNetwork.QHostAddress.Equals ( object  o)
override int QtNetwork.QHostAddress.GetHashCode ( )
new bool QtNetwork.QHostAddress.IsInSubnet ( QHostAddress  subnet,
int  netmask 
)

Returns true if this IP is in the subnet described by the network prefix subnet and netmask netmask.

An IP is considered to belong to a subnet if it is contained between the lowest and the highest address in that subnet. In the case of IP version 4, the lowest address is the network address, while the highest address is the broadcast address.

The subnet argument does not have to be the actual network address (the lowest address in the subnet). It can be any valid IP belonging to that subnet. In particular, if it is equal to the IP address held by this object, this function will always return true (provided the netmask is a valid value).

This function was introduced in Qt 4.5.

See also parseSubnet().

new bool QtNetwork.QHostAddress.IsInSubnet ( QPair< QHostAddress, System.Int32 >  subnet)

Returns true if this IP is in the subnet described by the network prefix subnet and netmask netmask.

An IP is considered to belong to a subnet if it is contained between the lowest and the highest address in that subnet. In the case of IP version 4, the lowest address is the network address, while the highest address is the broadcast address.

The subnet argument does not have to be the actual network address (the lowest address in the subnet). It can be any valid IP belonging to that subnet. In particular, if it is equal to the IP address held by this object, this function will always return true (provided the netmask is a valid value).

This function was introduced in Qt 4.5.

See also parseSubnet().

new bool QtNetwork.QHostAddress.IsNull ( )

Returns true if this host address is null (INADDR_ANY or in6addr_any). The default constructor creates a null address, and that address is not valid for any host or interface.

static bool QtNetwork.QHostAddress.operator!= ( QHostAddress  arg1,
QHostAddress  arg2 
)
static

Returns true if this host address is not the same as the other address given; otherwise returns false.

This function was introduced in Qt 4.2.

static bool QtNetwork.QHostAddress.operator!= ( QHostAddress  arg1,
QHostAddress.SpecialAddress  arg2 
)
static

Returns true if this host address is not the same as the other address given; otherwise returns false.

static bool QtNetwork.QHostAddress.operator== ( QHostAddress  arg1,
QHostAddress  arg2 
)
static

Returns true if this host address is the same as the other address given; otherwise returns false.

static bool QtNetwork.QHostAddress.operator== ( QHostAddress  arg1,
QHostAddress.SpecialAddress  arg2 
)
static

Returns true if this host address is the same as the other address given; otherwise returns false.

static QPair<QHostAddress,System.Int32> QtNetwork.QHostAddress.ParseSubnet ( string  subnet)
static

Parses the IP and subnet information contained in subnet and returns the network prefix for that network and its prefix length.

The IP address and the netmask must be separated by a slash (/).

This function supports arguments in the form:

123.123.123.123/n where n is any value between 0 and 32

123.123.123.123/255.255.255.255

<ipv6-address>/n where n is any value between 0 and 128

For IP version 4, this function accepts as well missing trailing components (i.e., less than 4 octets, like "192.168.1"), followed or not by a dot. If the netmask is also missing in that case, it is set to the number of octets actually passed (in the example above, it would be 24, for 3 octets).

This function was introduced in Qt 4.5.

See also isInSubnet().

new QAbstractSocket.NetworkLayerProtocol QtNetwork.QHostAddress.Protocol ( )

Returns the network layer protocol of the host address.

new void QtNetwork.QHostAddress.SetAddress ( QIPv6Address  ip6Addr)

Set the IPv4 address specified by ip4Addr.

new void QtNetwork.QHostAddress.SetAddress ( uint  ip4Addr)

Set the IPv4 address specified by ip4Addr.

new void QtNetwork.QHostAddress.SetAddress ( Pointer< byte >  ip6Addr)

Set the IPv4 address specified by ip4Addr.

new bool QtNetwork.QHostAddress.SetAddress ( string  address)

This is an overloaded function.

Sets the IPv4 or IPv6 address specified by the string representation specified by address (e.g. "127.0.0.1"). Returns true and sets the address if the address was successfully parsed; otherwise returns false.

new uint QtNetwork.QHostAddress.ToIPv4Address ( )

Returns the IPv4 address as a number.

For example, if the address is 127.0.0.1, the returned value is 2130706433 (i.e. 0x7f000001).

This value is only valid if the Protocol() is IPv4Protocol.

See also toString().

new QIPv6Address QtNetwork.QHostAddress.ToIPv6Address ( )

Returns the IPv6 address as a Q_IPV6ADDR structure. The structure consists of 16 unsigned characters.

Q_IPV6ADDR addr = hostAddr.toIPv6Address();

// addr contains 16 unsigned characters

for (int i = 0; i < 16; ++i) {

// process addr[i]

}

This value is only valid if the protocol() is IPv6Protocol.

See also toString().

override string QtNetwork.QHostAddress.ToString ( )

Returns the address as a string.

For example, if the address is the IPv4 address 127.0.0.1, the returned string is "127.0.0.1". For IPv6 the string format will follow the RFC5952 recommendation.

See also toIPv4Address().

Member Data Documentation

SmokeInvocation QtNetwork.QHostAddress.interceptor
protected

Property Documentation

new string QtNetwork.QHostAddress.ScopeId
getset

Returns the scope ID of an IPv6 address. For IPv4 addresses, or if the address does not contain a scope ID, an empty QString is returned.

The IPv6 scope ID specifies the scope of reachability for non-global IPv6 addresses, limiting the area in which the address can be used. All IPv6 addresses are associated with such a reachability scope. The scope ID is used to disambiguate addresses that are not guaranteed to be globally unique.

IPv6 specifies the following four levels of reachability:

Node-local: Addresses that are only used for communicating with services on the same interface (e.g., the loopback interface "::1").

Link-local: Addresses that are local to the network interface (link). There is always one link-local address for each IPv6 interface on your host. Link-local addresses ("fe80...") are generated from the MAC address of the local network adaptor, and are not guaranteed to be unique.

Site-local: Addresses that are local to the site / private network (e.g., the company intranet). Site-local addresses ("fec0...") are usually distributed by the site router, and are not guaranteed to be unique outside of the local site.

Global: For globally routable addresses, such as public servers on the Internet.

When using a link-local or site-local address for IPv6 connections, you must specify the scope ID. The scope ID for a link-local address is usually the same as the interface name (e.g., "eth0", "en1") or number (e.g., "1", "2").

This function was introduced in Qt 4.1.

Sets the IPv6 scope ID of the address to id. If the address protocol is not IPv6, this function does nothing.

This function was introduced in Qt 4.1.

virtual System.IntPtr QtNetwork.QHostAddress.SmokeObject
getset