Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions | ![]() |
The QHostAddress class provides an IP address. More...
#include <QHostAddress>
The QHostAddress class provides an IP address.
This class holds an IP address in a platform and protocol independent manner. It stores both IPv4 and IPv6 addresses in a way that you can easily access on any platform.
QHostAddress is normally used with the classes QSocket, QServerSocket, and QSocketDevice to set up a server, or to connect to a host.
A host address is set with setAddress(), checked for its type using isIPv4Address() or isIPv6Address(), and retrieved with toIPv4Address(), toIPv6Address(), or toString().
See also QSocket, QServerSocket, and QSocketDevice.
Creates a host address object with the IP address 0.0.0.0.
See also clear().
Creates a host address object for the IPv4 address, ip4Addr.
Creates a host address object for the specified IPv6 address.
ip6Addr must be an array of 16 bytes in network byte order (high-order byte first).
Creates a host address object for the IPv6 address, ip6Addr.
Creates a copy of the given address.
Destroys the host address object.
Sets the host address to 0.0.0.0.
Returns true if this host address represents an IPv4 address; otherwise returns false.
Returns true if this host address represents an IPv6 address; otherwise returns false.
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.
Set the IPv4 address specified by ip4Addr.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Set the IPv6 address specified by ip6Addr.
ip6Addr must be an array of 16 bytes in network byte order (high-order byte first).
This is an overloaded member function, provided for convenience. It behaves essentially like the above 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.
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 isIp4Addr() returns true.
See also toString().
Returns the IPv6 address as a Q_IPV6ADDR structure. The structure consists of 16 unsigned characters.
Q_IPV6ADDR addr = hostAddr.ip6Addr(); // addr.c[] contains 16 unsigned characters for (int i = 0; i < 16; ++i) { // process addr.c[i] }
This value is only valid if isIPv6Address() returns true.
See also 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".
See also toIPv4Address().
Assigns another host address to this object, and returns a reference to this object.
Returns true if this host address is the same as the other address given; otherwise returns false.
Copyright © 2004 Trolltech. | Trademarks | Qt 4.0.0-tp1 |