QHostAddress Class ReferenceThe QHostAddress class provides an IP address. Далее... #include <QHostAddress>
Открытые типы
Открытые функции
Статические открытые члены
Связанные нечлены класса
Подробное описание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. Описание типов-членовenum QHostAddress::SpecialAddress
Описание функций-членовQHostAddress::QHostAddress ()Constructs a host address object with the IP address 0.0.0.0. See also clear(). QHostAddress::QHostAddress ( quint32 ip4Addr )Constructs a host address object with the IPv4 address ip4Addr. QHostAddress::QHostAddress ( quint8 * ip6Addr )Constructs a host address object with the IPv6 address ip6Addr. ip6Addr must be a 16-byte array in network byte order (big endian). QHostAddress::QHostAddress ( const Q_IPV6ADDR & ip6Addr )Constructs a host address object with the IPv6 address ip6Addr. QHostAddress::QHostAddress ( const sockaddr * sockaddr )Constructs an IPv4 or IPv6 address using the address specified by the native structure sockaddr. See also setAddress(). QHostAddress::QHostAddress ( const QString & address )Constructs an IPv4 or IPv6 address based on the string address (e.g., "127.0.0.1"). See also setAddress(). QHostAddress::QHostAddress ( const QHostAddress & address )Constructs a copy of the given address. QHostAddress::QHostAddress ( SpecialAddress address )Constructs a QHostAddress object for address. QHostAddress::~QHostAddress ()Destroys the host address object. void QHostAddress::clear ()Sets the host address to 0.0.0.0. bool QHostAddress::isInSubnet ( const QHostAddress & subnet, int netmask ) constReturns 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). Эта функция была введена в Qt 4.5. See also parseSubnet(). bool QHostAddress::isInSubnet ( const QPair<QHostAddress, int> & subnet ) constЭто перегруженная функция. Returns true if this IP is in the subnet described by subnet. The QHostAddress member of subnet contains the network prefix and the int (second) member contains the netmask (prefix length). Эта функция была введена в Qt 4.5. bool QHostAddress::isNull () constReturns 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. QPair<QHostAddress, int> QHostAddress::parseSubnet ( const QString & 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:
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). Эта функция была введена в Qt 4.5. See also isInSubnet(). QAbstractSocket::NetworkLayerProtocol QHostAddress::protocol () constReturns the network layer protocol of the host address. QString QHostAddress::scopeId () constReturns 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:
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"). Эта функция была введена в Qt 4.1. See also setScopeId(). void QHostAddress::setAddress ( quint32 ip4Addr )Set the IPv4 address specified by ip4Addr. void QHostAddress::setAddress ( quint8 * ip6Addr )Это перегруженная функция. Set the IPv6 address specified by ip6Addr. ip6Addr must be an array of 16 bytes in network byte order (high-order byte first). void QHostAddress::setAddress ( const Q_IPV6ADDR & ip6Addr )Это перегруженная функция. Set the IPv6 address specified by ip6Addr. bool QHostAddress::setAddress ( const QString & address )Это перегруженная функция. 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. void QHostAddress::setAddress ( const sockaddr * sockaddr )Это перегруженная функция. Sets the IPv4 or IPv6 address specified by the native structure sockaddr. Returns true and sets the address if the address was successfully parsed; otherwise returns false. void QHostAddress::setScopeId ( const QString & id )Sets the IPv6 scope ID of the address to id. If the address protocol is not IPv6, this function does nothing. Эта функция была введена в Qt 4.1. See also scopeId(). quint32 QHostAddress::toIPv4Address () constReturns 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. Смотрите также toString(). Q_IPV6ADDR QHostAddress::toIPv6Address () constReturns 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. Смотрите также toString(). QString QHostAddress::toString () constReturns 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(). bool QHostAddress::operator!= ( const QHostAddress & other ) constReturns true if this host address is not the same as the other address given; otherwise returns false. Эта функция была введена в Qt 4.2. bool QHostAddress::operator!= ( SpecialAddress other ) constReturns true if this host address is not the same as the other address given; otherwise returns false. QHostAddress & QHostAddress::operator= ( const QHostAddress & address )Assigns another host address to this object, and returns a reference to this object. QHostAddress & QHostAddress::operator= ( const QString & address )Assigns the host address address to this object, and returns a reference to this object. See also setAddress(). bool QHostAddress::operator== ( const QHostAddress & other ) constReturns true if this host address is the same as the other address given; otherwise returns false. bool QHostAddress::operator== ( SpecialAddress other ) constReturns true if this host address is the same as the other address given; otherwise returns false. Связанные нечлены классаQDataStream & operator<< ( QDataStream & out, const QHostAddress & address )Writes host address address to the stream out and returns a reference to the stream. Смотрите также Преобразование типов данных Qt в последовательный вид. QDataStream & operator>> ( QDataStream & in, QHostAddress & address )Reads a host address into address from the stream in and returns a reference to the stream. Смотрите также Преобразование типов данных Qt в последовательный вид. |
Попытка перевода Qt документации. Если есть желание присоединиться, или если есть замечания или пожелания, то заходите на форум: Перевод Qt документации на русский язык... Люди внесшие вклад в перевод: Команда переводчиков |