Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QNetworkAddressEntry Class

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

Header:#include <QNetworkAddressEntry>
Since: Qt 4.2

Note: All functions in this class arereentrant.

Public Functions

QNetworkAddressEntry()
QNetworkAddressEntry(const QNetworkAddressEntry & other)
~QNetworkAddressEntry()
QHostAddressbroadcast() const
QHostAddressip() const
QHostAddressnetmask() const
intprefixLength() const
voidsetBroadcast(const QHostAddress & newBroadcast)
voidsetIp(const QHostAddress & newIp)
voidsetNetmask(const QHostAddress & newNetmask)
voidsetPrefixLength(int length)
booloperator!=(const QNetworkAddressEntry & other) const
QNetworkAddressEntry &operator=(const QNetworkAddressEntry & other)
booloperator==(const QNetworkAddressEntry & other) const

Detailed Description

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

Each network interface can contain zero or more IP addresses, which in turn can be associated with a netmask and/or a broadcast address (depending on support from the operating system).

This class represents one such group.

Member Function Documentation

QNetworkAddressEntry::QNetworkAddressEntry()

Constructs an emptyQNetworkAddressEntry object.

QNetworkAddressEntry::QNetworkAddressEntry(constQNetworkAddressEntry & other)

Constructs aQNetworkAddressEntry object that is a copy of the objectother.

QNetworkAddressEntry::~QNetworkAddressEntry()

Destroys thisQNetworkAddressEntry object.

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).

See alsosetBroadcast().

QHostAddress QNetworkAddressEntry::ip() const

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

See alsosetIp().

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 aQHostAddress holding the address FFFF:FFFF:FFFF:FFFF::

See alsosetNetmask() andprefixLength().

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 (seenetmask()). 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()).

This function was introduced in Qt 4.5.

See alsosetPrefixLength() andnetmask().

void QNetworkAddressEntry::setBroadcast(constQHostAddress & newBroadcast)

Sets the broadcast IP address of thisQNetworkAddressEntry object tonewBroadcast.

See alsobroadcast().

void QNetworkAddressEntry::setIp(constQHostAddress & newIp)

Sets the IP address theQNetworkAddressEntry object contains tonewIp.

See alsoip().

void QNetworkAddressEntry::setNetmask(constQHostAddress & newNetmask)

Sets the netmask that thisQNetworkAddressEntry object contains tonewNetmask. Setting the netmask also sets the prefix length to match the new netmask.

See alsonetmask() andsetPrefixLength().

void QNetworkAddressEntry::setPrefixLength(int length)

Sets the prefix length of this IP address tolength. The value oflength 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 (seenetmask()).

This function was introduced in Qt 4.5.

See alsoprefixLength() andsetNetmask().

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

Returns true if this network address entry is different fromother.

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

Makes a copy of theQNetworkAddressEntry objectother.

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

Returns true if this network address entry is the same asother.

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp