QNetworkAddressEntry 類

The QNetworkAddressEntry class stores one IP address supported by a network interface, along with its associated netmask and broadcast address. 更多...

頭: #include <QNetworkAddressEntry>
qmake: QT += network
Since: Qt 4.2

注意: 此類的所有函數 可重入 .

公共函數

QNetworkAddressEntry ()
QNetworkAddressEntry (const QNetworkAddressEntry & other )
~QNetworkAddressEntry ()
QHostAddress broadcast () const
QHostAddress ip () const
QHostAddress netmask () const
int prefixLength () const
void setBroadcast (const QHostAddress & newBroadcast )
void setIp (const QHostAddress & newIp )
void setNetmask (const QHostAddress & newNetmask )
void setPrefixLength (int length )
void swap (QNetworkAddressEntry & other )
bool operator!= (const QNetworkAddressEntry & other ) const
QNetworkAddressEntry & operator= (QNetworkAddressEntry && other )
QNetworkAddressEntry & operator= (const QNetworkAddressEntry & other )
bool operator== (const QNetworkAddressEntry & other ) const

詳細描述

The QNetworkAddressEntry class stores one IP address supported by a network interface, along with its associated netmask and broadcast address.

每個網絡接口可以包含零個或多個 IP 地址,可以依次關聯 Netmask (網絡掩碼) 和/或廣播地址 (取決於操作係統是否支持)。

此類錶示一個這樣的組。

成員函數文檔編製

QNetworkAddressEntry:: QNetworkAddressEntry ()

構造空的 QNetworkAddressEntry 對象。

QNetworkAddressEntry:: QNetworkAddressEntry (const QNetworkAddressEntry & other )

構造 QNetworkAddressEntry object that is a copy of the object other .

QNetworkAddressEntry:: ~QNetworkAddressEntry ()

銷毀此 QNetworkAddressEntry 對象。

QHostAddress QNetworkAddressEntry:: broadcast () const

Returns the broadcast address associated with the IPv4 address and netmask. It can usually be derived from those two by setting to 1 the bits of the IP address where the netmask contains a 0. (In other words, by bitwise-OR'ing the IP address with the inverse of the netmask)

This member is always empty for IPv6 addresses, since the concept of broadcast has been abandoned in that system in favor of multicast. In particular, the group of hosts corresponding to all the nodes in the local network can be reached by the "all-nodes" special multicast group (address FF02::1).

另請參閱 setBroadcast ().

QHostAddress QNetworkAddressEntry:: ip () const

This function returns one IPv4 or IPv6 address found, that was found in a network interface.

另請參閱 setIp ().

QHostAddress QNetworkAddressEntry:: netmask () const

Returns the netmask associated with the IP address. The netmask is expressed in the form of an IP address, such as 255.255.0.0.

For IPv6 addresses, the prefix length is converted to an address where the number of bits set to 1 is equal to the prefix length. For a prefix length of 64 bits (the most common value), the netmask will be expressed as a QHostAddress holding the address FFFF:FFFF:FFFF:FFFF::

另請參閱 setNetmask () 和 prefixLength ().

int QNetworkAddressEntry:: prefixLength () const

Returns the prefix length of this IP address. The prefix length matches the number of bits set to 1 in the netmask (see netmask ()). For IPv4 addresses, the value is between 0 and 32. For IPv6 addresses, it's contained between 0 and 128 and is the preferred form of representing addresses.

This function returns -1 if the prefix length could not be determined (i.e., netmask () returns a null QHostAddress()).

該函數在 Qt 4.5 引入。

另請參閱 setPrefixLength () 和 netmask ().

void QNetworkAddressEntry:: setBroadcast (const QHostAddress & newBroadcast )

Sets the broadcast IP address of this QNetworkAddressEntry 對象到 newBroadcast .

另請參閱 broadcast ().

void QNetworkAddressEntry:: setIp (const QHostAddress & newIp )

Sets the IP address the QNetworkAddressEntry object contains to newIp .

另請參閱 ip ().

void QNetworkAddressEntry:: setNetmask (const QHostAddress & newNetmask )

Sets the netmask that this QNetworkAddressEntry object contains to newNetmask . Setting the netmask also sets the prefix length to match the new netmask.

另請參閱 netmask () 和 setPrefixLength ().

void QNetworkAddressEntry:: setPrefixLength ( int length )

Sets the prefix length of this IP address to length . The value of length must be valid for this type of IP address: between 0 and 32 for IPv4 addresses, between 0 and 128 for IPv6 addresses. Setting to any invalid value is equivalent to setting to -1, which means "no prefix length".

Setting the prefix length also sets the netmask (see netmask ()).

該函數在 Qt 4.5 引入。

另請參閱 prefixLength () 和 setNetmask ().

void QNetworkAddressEntry:: swap ( QNetworkAddressEntry & other )

Swaps this network address entry instance with other 。此函數非常快且從不失敗。

該函數在 Qt 5.0 引入。

bool QNetworkAddressEntry:: operator!= (const QNetworkAddressEntry & other ) const

返迴 true 若此網絡地址條目不同於 other .

QNetworkAddressEntry &QNetworkAddressEntry:: operator= ( QNetworkAddressEntry && other )

移動賦值運算符。

QNetworkAddressEntry &QNetworkAddressEntry:: operator= (const QNetworkAddressEntry & other )

Makes a copy of the QNetworkAddressEntry 對象 other .

bool QNetworkAddressEntry:: operator== (const QNetworkAddressEntry & other ) const

返迴 true 若此網絡地址條目等同 other .