XMPP::NetInterfaceManager Class Reference

Manages network interface information. More...

#include <netinterface.h>

List of all members.

Signals

void interfaceAvailable (const QString &id)

Public Member Functions

 NetInterfaceManager (QObject *parent=0)
 ~NetInterfaceManager ()
QStringList interfaces () const

Static Public Member Functions

static QString interfaceForAddress (const QHostAddress &a)


Detailed Description

Manages network interface information.

NetInterfaceManager keeps track of all available network interfaces.

An interface is considered available if it exists, is "Up", has at least one IP address, and is non-Loopback.

The interfaces() function returns a list of available interface ids. These ids can be used with NetInterface to get information about the interfaces. For example, here is how you could print the names of the available interfaces:

NetInterfaceManager netman;
QStringList id_list = netman.interfaces();
for(int n = 0; n < id_list.count(); ++n)
{
        NetInterface iface(id_list[n], &netman);
        printf("name: [%s]\n", qPrintable(iface.name()));
}

When a new network interface is available, the interfaceAvailable() signal will be emitted. Note that interface unavailability is not notified by NetInterfaceManager. Instead, use NetInterface to monitor a specific network interface for unavailability.

Interface ids obtained through NetInterfaceManager are guaranteed to be valid until the event loop resumes, or until the next call to interfaces() or interfaceForAddress().

See also:
NetInterface


Constructor & Destructor Documentation

XMPP::NetInterfaceManager::NetInterfaceManager QObject *  parent = 0  ) 
 

Constructs a new manager object with the given parent.

XMPP::NetInterfaceManager::~NetInterfaceManager  ) 
 

Destroys the manager object.


Member Function Documentation

void XMPP::NetInterfaceManager::interfaceAvailable const QString &  id  )  [signal]
 

Notifies when an interface becomes available.

The id parameter is the interface id, ready to use with NetInterface.

static QString XMPP::NetInterfaceManager::interfaceForAddress const QHostAddress &  a  )  [static]
 

Looks up an interface id by IP address.

This function looks for an interface that has the address a. If there is no such interface, a null string is returned.

This is useful for determing the network interface associated with an outgoing QTcpSocket:

QString iface = NetInterfaceManager::interfaceForAddress(tcpSocket->localAddress());

See also:
interfaces

QStringList XMPP::NetInterfaceManager::interfaces  )  const
 

Returns the list of available interface ids.

See also:
interfaceAvailable

interfaceForAddress


The documentation for this class was generated from the following file:
Generated on Sun Mar 18 17:58:51 2007 for IrisNet by  doxygen 1.4.6