Qt:Документация 4.3.2/qnetworkinterface

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск
40px Внимание: Актуальная версия перевода документации находится здесь

__NOTOC__

Image:qt-logo.png

Главная · Все классы · Основные классы · Классы по группам · Модули · Функции

Image:trolltech-logo.png

Содержание

[править] QNetworkInterface Class Reference
[модуль QtNetwork ]

The QNetworkInterface class provides a listing of the host's IP addresses and network interfaces. Далее...

 #include <QNetworkInterface>

Примечание: все функции в этом классе реентерабельны.

Класс был добавлен в Qt 4.2.

[править] Открытые типы

[править] Открытые функции

[править] Статические открытые члены


[править] Подробное описание

The QNetworkInterface class provides a listing of the host's IP addresses and network interfaces.

QNetworkInterface represents one network interface attached to the host where the program is being run. Each network interface may contain zero or more IP addresses, each of which is optionally associated with a netmask and/or a broadcast address. The list of such trios can be obtained with addressEntries(). Alternatively, when the netmask or the broadcast addresses aren't necessary, use the allAddresses() convenience function to obtain just the IP addresses.

QNetworkInterface also reports the interface's hardware address with hardwareAddress().

Not all operating systems support reporting all features. Only the IPv4 addresses are guaranteed to be listed by this class in all platforms. In particular, IPv6 address listing is only supported on Windows XP and more recent versions, Linux, MacOS X and the BSDs.

See also QNetworkAddressEntry.


[править] Описание типов

[править]
enum QNetworkInterface::InterfaceFlag
flags QNetworkInterface::InterfaceFlags

Specifies the flags associated with this network interface. The possible values are:


Константа Значение Описание
QNetworkInterface::IsUp 0x1 the network interface is active
QNetworkInterface::IsRunning 0x2 the network interface has resources allocated
QNetworkInterface::CanBroadcast 0x4 the network interface works in broadcast mode
QNetworkInterface::IsLoopBack 0x8 the network interface is a loopback interface: that is, it's a virtual interface whose destination is the host computer itself
QNetworkInterface::IsPointToPoint 0x10 the network interface is a point-to-point interface: that is, there is one, single other address that can be directly reached by it.
QNetworkInterface::CanMulticast 0x20 the network interface supports multicasting

Note that one network interface cannot be both broadcast-based and point-to-point.

The InterfaceFlags type is a typedef for QFlags<InterfaceFlag>. It stores an OR combination of InterfaceFlag values.


[править] Описание функций-членов

[править]
QNetworkInterface::QNetworkInterface ()

Constructs an empty network interface object.

[править]
QNetworkInterface::QNetworkInterface ( const QNetworkInterface & other )

Creates a copy of the the QNetworkInterface object contained in other.

[править]
QNetworkInterface::~QNetworkInterface ()

Frees the resources associated with the QNetworkInterface object.

[править]
QList< QNetworkAddressEntry> QNetworkInterface::addressEntries () const

Returns the list of IP addresses that this interface possesses along with their associated netmasks and broadcast addresses.

If the netmask or broadcast address information is not necessary, you can call the allAddresses() function to obtain just the IP addresses.

[править]
QList< QHostAddress> QNetworkInterface::allAddresses () [static]

This convenience function returns all IP addresses found on the host machine. It is equivalent to calling addressEntries() on all the objects returned by allInterfaces() to obtain lists of QHostAddress objects then calling QHostAddress::ip() on each of these.

[править]
QList<QNetworkInterface> QNetworkInterface::allInterfaces () [static]

Returns a listing of all the network interfaces found on the host machine.

[править]
InterfaceFlags QNetworkInterface::flags () const

Returns the flags associated with this network interface.

[править]
QString QNetworkInterface::hardwareAddress () const

Returns the low-level hardware address for this interface. On Ethernet interfaces, this will be a MAC address in string representation, separated by colons.

Other interface types may have other types of hardware addresses. Implementations should not depend on this function returning a valid MAC address.

[править]
QNetworkInterface QNetworkInterface::interfaceFromIndex ( int index ) [static]

Returns a QNetworkInterface object for the interface whose internal ID is index. Network interfaces have a unique identifier called the "interface index" to distinguish it from other interfaces on the system. Often, this value is assigned progressively and interfaces being removed and then added again get a different value every time.

This index is also found in the IPv6 address' scope ID field.

[править]
QNetworkInterface QNetworkInterface::interfaceFromName ( const QString & name ) [static]

Returns a QNetworkInterface object for the interface named name. If no such interface exists, this function returns an invalid QNetworkInterface object.

See also name() and isValid().

[править]
bool QNetworkInterface::isValid () const

Returns true if this QNetworkInterface object contains valid information about a network interface.

[править]
QString QNetworkInterface::name () const

Returns the name of this network interface. On Unix systems, this is a string containing the type of the interface and optionally a sequence number, such as "eth0", "lo" or "pcn0". On Windows, it's an internal ID that cannot be changed by the user.

[править]
QNetworkInterface & QNetworkInterface::operator= ( const QNetworkInterface & other )

Copies the contents of the QNetworkInterface object contained in other into this one.



Copyright © 2007 Trolltech Trademarks
Qt 4.3.2