<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html><head><title>QNetworkInterface Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } td.postheader { font-family: sans-serif } tr.address { font-family: sans-serif } body { background: #ffffff; color: black; } </style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QNetworkInterface Class Reference<br /><sup><sup>[<a href="qtnetwork.html">QtNetwork</a> module]</sup></sup></h1><p>The QNetworkInterface class provides a listing of the host's IP addresses and network interfaces. <a href="#details">More...</a></p> <h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qnetworkinterface.html#InterfaceFlag-enum">InterfaceFlag</a></b> { IsUp, IsRunning, CanBroadcast, IsLoopBack, IsPointToPoint, CanMulticast }</li><li><div class="fn" />class <b><a href="qnetworkinterface-interfaceflags.html">InterfaceFlags</a></b></li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qnetworkinterface.html#QNetworkInterface">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qnetworkinterface.html#QNetworkInterface-2">__init__</a></b> (<i>self</i>, QNetworkInterface <i>other</i>)</li><li><div class="fn" />list-of-QNetworkAddressEntry <b><a href="qnetworkinterface.html#addressEntries">addressEntries</a></b> (<i>self</i>)</li><li><div class="fn" />InterfaceFlags <b><a href="qnetworkinterface.html#flags">flags</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qnetworkinterface.html#hardwareAddress">hardwareAddress</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qnetworkinterface.html#humanReadableName">humanReadableName</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qnetworkinterface.html#index">index</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qnetworkinterface.html#isValid">isValid</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qnetworkinterface.html#name">name</a></b> (<i>self</i>)</li></ul><h3>Static Methods</h3><ul><li><div class="fn" />list-of-QHostAddress <b><a href="qnetworkinterface.html#allAddresses">allAddresses</a></b> ()</li><li><div class="fn" />list-of-QNetworkInterface <b><a href="qnetworkinterface.html#allInterfaces">allInterfaces</a></b> ()</li><li><div class="fn" />QNetworkInterface <b><a href="qnetworkinterface.html#interfaceFromIndex">interfaceFromIndex</a></b> (int <i>index</i>)</li><li><div class="fn" />QNetworkInterface <b><a href="qnetworkinterface.html#interfaceFromName">interfaceFromName</a></b> (QString <i>name</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QNetworkInterface class provides a listing of the host's IP addresses and network interfaces.</p> <p>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 <a href="qnetworkinterface.html#addressEntries">addressEntries</a>(). Alternatively, when the netmask or the broadcast addresses aren't necessary, use the <a href="qnetworkinterface.html#allAddresses">allAddresses</a>() convenience function to obtain just the IP addresses.</p> <p>QNetworkInterface also reports the interface's hardware address with <a href="qnetworkinterface.html#hardwareAddress">hardwareAddress</a>().</p> <p>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.</p> <hr /><h2>Type Documentation</h2><h3 class="fn"><a name="InterfaceFlag-enum" />QNetworkInterface.InterfaceFlag</h3><p>Specifies the flags associated with this network interface. The possible values are:</p> <table class="valuelist"> <tr class="odd" valign="top"> <th class="tblConst">Constant</th> <th class="tblval">Value</th> <th class="tbldscr">Description</th> </tr> <tr> <td class="topAlign"><tt>QNetworkInterface.IsUp</tt></td> <td class="topAlign"><tt>0x1</tt></td> <td class="topAlign">the network interface is active</td> </tr> <tr> <td class="topAlign"><tt>QNetworkInterface.IsRunning</tt></td> <td class="topAlign"><tt>0x2</tt></td> <td class="topAlign">the network interface has resources allocated</td> </tr> <tr> <td class="topAlign"><tt>QNetworkInterface.CanBroadcast</tt></td> <td class="topAlign"><tt>0x4</tt></td> <td class="topAlign">the network interface works in broadcast mode</td> </tr> <tr> <td class="topAlign"><tt>QNetworkInterface.IsLoopBack</tt></td> <td class="topAlign"><tt>0x8</tt></td> <td class="topAlign">the network interface is a loopback interface: that is, it's a virtual interface whose destination is the host computer itself</td> </tr> <tr> <td class="topAlign"> <tt>QNetworkInterface.IsPointToPoint</tt></td> <td class="topAlign"><tt>0x10</tt></td> <td class="topAlign">the network interface is a point-to-point interface: that is, there is one, single other address that can be directly reached by it.</td> </tr> <tr> <td class="topAlign"><tt>QNetworkInterface.CanMulticast</tt></td> <td class="topAlign"><tt>0x20</tt></td> <td class="topAlign">the network interface supports multicasting</td> </tr> </table> <p>Note that one network interface cannot be both broadcast-based and point-to-point.</p> <p>The InterfaceFlags type is a typedef for <a href="qflags.html">QFlags</a><InterfaceFlag>. It stores an OR combination of InterfaceFlag values.</p> <hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QNetworkInterface" />QNetworkInterface.__init__ (<i>self</i>)</h3><p>Constructs an empty network interface object.</p> <h3 class="fn"><a name="QNetworkInterface-2" />QNetworkInterface.__init__ (<i>self</i>, <a href="qnetworkinterface.html">QNetworkInterface</a> <i>other</i>)</h3><p>Creates a copy of the <a href="qnetworkinterface.html">QNetworkInterface</a> object contained in <i>other</i>.</p> <h3 class="fn"><a name="addressEntries" />list-of-QNetworkAddressEntry QNetworkInterface.addressEntries (<i>self</i>)</h3><p>Returns the list of IP addresses that this interface possesses along with their associated netmasks and broadcast addresses.</p> <p>If the netmask or broadcast address information is not necessary, you can call the <a href="qnetworkinterface.html#allAddresses">allAddresses</a>() function to obtain just the IP addresses.</p> <h3 class="fn"><a name="allAddresses" />list-of-QHostAddress QNetworkInterface.allAddresses ()</h3><p>This convenience function returns all IP addresses found on the host machine. It is equivalent to calling <a href="qnetworkinterface.html#addressEntries">addressEntries</a>() on all the objects returned by <a href="qnetworkinterface.html#allInterfaces">allInterfaces</a>() to obtain lists of <a href="qhostaddress.html">QHostAddress</a> objects then calling QHostAddress.ip() on each of these.</p> <h3 class="fn"><a name="allInterfaces" />list-of-QNetworkInterface QNetworkInterface.allInterfaces ()</h3><p>Returns a listing of all the network interfaces found on the host machine.</p> <h3 class="fn"><a name="flags" /><a href="qnetworkinterface-interfaceflags.html">InterfaceFlags</a> QNetworkInterface.flags (<i>self</i>)</h3><p>Returns the flags associated with this network interface.</p> <h3 class="fn"><a name="hardwareAddress" />QString QNetworkInterface.hardwareAddress (<i>self</i>)</h3><p>Returns the low-level hardware address for this interface. On Ethernet interfaces, this will be a MAC address in string representation, separated by colons.</p> <p>Other interface types may have other types of hardware addresses. Implementations should not depend on this function returning a valid MAC address.</p> <h3 class="fn"><a name="humanReadableName" />QString QNetworkInterface.humanReadableName (<i>self</i>)</h3><p>Returns the human-readable name of this network interface on Windows, such as "Local Area Connection", if the name could be determined. If it couldn't, this function returns the same as <a href="qnetworkinterface.html#name">name</a>(). The human-readable name is a name that the user can modify in the Windows Control Panel, so it may change during the execution of the program.</p> <p>On Unix, this function currently always returns the same as <a href="qnetworkinterface.html#name">name</a>(), since Unix systems don't store a configuration for human-readable names.</p> <p>This function was introduced in Qt 4.5.</p> <h3 class="fn"><a name="index" />int QNetworkInterface.index (<i>self</i>)</h3><p>Returns the interface system index, if known. This is an integer assigned by the operating system to identify this interface and it generally doesn't change. It matches the scope ID field in IPv6 addresses.</p> <p>If the index isn't known, this function returns 0.</p> <p>This function was introduced in Qt 4.5.</p> <h3 class="fn"><a name="interfaceFromIndex" /><a href="qnetworkinterface.html">QNetworkInterface</a> QNetworkInterface.interfaceFromIndex (int <i>index</i>)</h3><p>Returns a <a href="qnetworkinterface.html">QNetworkInterface</a> object for the interface whose internal ID is <i>index</i>. 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.</p> <p>This index is also found in the IPv6 address' scope ID field.</p> <h3 class="fn"><a name="interfaceFromName" /><a href="qnetworkinterface.html">QNetworkInterface</a> QNetworkInterface.interfaceFromName (QString <i>name</i>)</h3><p>Returns a <a href="qnetworkinterface.html">QNetworkInterface</a> object for the interface named <i>name</i>. If no such interface exists, this function returns an invalid <a href="qnetworkinterface.html">QNetworkInterface</a> object.</p> <p><b>See also</b> <a href="qnetworkinterface.html#name">name</a>() and <a href="qnetworkinterface.html#isValid">isValid</a>().</p> <h3 class="fn"><a name="isValid" />bool QNetworkInterface.isValid (<i>self</i>)</h3><p>Returns true if this <a href="qnetworkinterface.html">QNetworkInterface</a> object contains valid information about a network interface.</p> <h3 class="fn"><a name="name" />QString QNetworkInterface.name (<i>self</i>)</h3><p>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.</p> <address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.10.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.5</td></tr></table></div></address></body></html>