File: qnetworkinterface.html

package info (click to toggle)
qt4-x11 4%3A4.8.2%2Bdfsg-11
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 701,696 kB
  • sloc: cpp: 2,686,179; ansic: 375,485; python: 25,859; sh: 19,349; xml: 17,091; perl: 14,765; yacc: 5,383; asm: 5,038; makefile: 1,259; lex: 555; ruby: 526; objc: 347; cs: 112; pascal: 112; php: 54; sed: 34
file content (197 lines) | stat: -rw-r--r-- 18,190 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qnetworkinterface.cpp -->
  <title>Qt 4.8: QNetworkInterface Class Reference</title>
  <link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="content"> 
    <a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
  </div>
  <div class="breadcrumb toolblock">
    <ul>
      <li class="first"><a href="index.html">Home</a></li>
      <!--  Breadcrumbs go here -->
<li><a href="modules.html">Modules</a></li>
<li><a href="qtnetwork.html">QtNetwork</a></li>
<li>QNetworkInterface</li>
    </ul>
  </div>
</div>
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-types">Public Types</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#static-public-members">Static Public Members</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<h1 class="title">QNetworkInterface Class Reference</h1>
<!-- $$$QNetworkInterface-brief -->
<p>The QNetworkInterface class provides a listing of the host's IP addresses and network interfaces. <a href="#details">More...</a></p>
<!-- @@@QNetworkInterface -->
<pre class="cpp"> <span class="preprocessor">#include &lt;QNetworkInterface&gt;</span></pre><p><b>Note:</b> All functions in this class are <a href="threads-reentrancy.html#reentrant">reentrant</a>.</p>
<p>This class was introduced in Qt 4.2.</p>
<ul>
<li><a href="qnetworkinterface-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-types"></a>
<h2>Public Types</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qnetworkinterface.html#InterfaceFlag-enum">InterfaceFlag</a></b> { IsUp, IsRunning, CanBroadcast, IsLoopBack, IsPointToPoint, CanMulticast }</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> flags </td><td class="memItemRight bottomAlign"><b><a href="qnetworkinterface.html#InterfaceFlag-enum">InterfaceFlags</a></b></td></tr>
</table>
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qnetworkinterface.html#QNetworkInterface">QNetworkInterface</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qnetworkinterface.html#QNetworkInterface-2">QNetworkInterface</a></b> ( const QNetworkInterface &amp; <i>other</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qnetworkinterface.html#dtor.QNetworkInterface">~QNetworkInterface</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;QNetworkAddressEntry&gt; </td><td class="memItemRight bottomAlign"><b><a href="qnetworkinterface.html#addressEntries">addressEntries</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> InterfaceFlags </td><td class="memItemRight bottomAlign"><b><a href="qnetworkinterface.html#flags">flags</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qnetworkinterface.html#hardwareAddress">hardwareAddress</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qnetworkinterface.html#humanReadableName">humanReadableName</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qnetworkinterface.html#index">index</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qnetworkinterface.html#isValid">isValid</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qnetworkinterface.html#name">name</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QNetworkInterface &amp; </td><td class="memItemRight bottomAlign"><b><a href="qnetworkinterface.html#operator-eq">operator=</a></b> ( const QNetworkInterface &amp; <i>other</i> )</td></tr>
</table>
<a name="static-public-members"></a>
<h2>Static Public Members</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;QHostAddress&gt; </td><td class="memItemRight bottomAlign"><b><a href="qnetworkinterface.html#allAddresses">allAddresses</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;QNetworkInterface&gt; </td><td class="memItemRight bottomAlign"><b><a href="qnetworkinterface.html#allInterfaces">allInterfaces</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QNetworkInterface </td><td class="memItemRight bottomAlign"><b><a href="qnetworkinterface.html#interfaceFromIndex">interfaceFromIndex</a></b> ( int <i>index</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QNetworkInterface </td><td class="memItemRight bottomAlign"><b><a href="qnetworkinterface.html#interfaceFromName">interfaceFromName</a></b> ( const QString &amp; <i>name</i> )</td></tr>
</table>
<a name="details"></a>
<!-- $$$QNetworkInterface-description -->
<div class="descr">
<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>
</div>
<p><b>See also </b><a href="qnetworkaddressentry.html">QNetworkAddressEntry</a>.</p>
<!-- @@@QNetworkInterface -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$InterfaceFlag$$$IsUp$$$IsRunning$$$CanBroadcast$$$IsLoopBack$$$IsPointToPoint$$$CanMulticast -->
<h3 class="flags"><a name="InterfaceFlag-enum"></a>enum QNetworkInterface::<span class="name">InterfaceFlag</span><br/>flags QNetworkInterface::<span class="name">InterfaceFlags</span></h3>
<p>Specifies the flags associated with this network interface. The possible values are:</p>
<table class="valuelist"><tr valign="top" class="odd"><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>&lt;InterfaceFlag&gt;. It stores an OR combination of InterfaceFlag values.</p>
<!-- @@@InterfaceFlag -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QNetworkInterface[overload1]$$$QNetworkInterface -->
<h3 class="fn"><a name="QNetworkInterface"></a>QNetworkInterface::<span class="name">QNetworkInterface</span> ()</h3>
<p>Constructs an empty network interface object.</p>
<!-- @@@QNetworkInterface -->
<!-- $$$QNetworkInterface$$$QNetworkInterfaceconstQNetworkInterface& -->
<h3 class="fn"><a name="QNetworkInterface-2"></a>QNetworkInterface::<span class="name">QNetworkInterface</span> ( const <span class="type">QNetworkInterface</span> &amp; <i>other</i> )</h3>
<p>Creates a copy of the <a href="qnetworkinterface.html">QNetworkInterface</a> object contained in <i>other</i>.</p>
<!-- @@@QNetworkInterface -->
<!-- $$$~QNetworkInterface[overload1]$$$~QNetworkInterface -->
<h3 class="fn"><a name="dtor.QNetworkInterface"></a>QNetworkInterface::<span class="name">~QNetworkInterface</span> ()</h3>
<p>Frees the resources associated with the <a href="qnetworkinterface.html">QNetworkInterface</a> object.</p>
<!-- @@@~QNetworkInterface -->
<!-- $$$addressEntries[overload1]$$$addressEntries -->
<h3 class="fn"><a name="addressEntries"></a><span class="type"><a href="qlist.html">QList</a></span>&lt;<span class="type"><a href="qnetworkaddressentry.html">QNetworkAddressEntry</a></span>&gt; QNetworkInterface::<span class="name">addressEntries</span> () const</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>
<!-- @@@addressEntries -->
<!-- $$$allAddresses[overload1]$$$allAddresses -->
<h3 class="fn"><a name="allAddresses"></a><span class="type"><a href="qlist.html">QList</a></span>&lt;<span class="type"><a href="qhostaddress.html">QHostAddress</a></span>&gt; QNetworkInterface::<span class="name">allAddresses</span> ()<tt> [static]</tt></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>
<!-- @@@allAddresses -->
<!-- $$$allInterfaces[overload1]$$$allInterfaces -->
<h3 class="fn"><a name="allInterfaces"></a><span class="type"><a href="qlist.html">QList</a></span>&lt;<span class="type">QNetworkInterface</span>&gt; QNetworkInterface::<span class="name">allInterfaces</span> ()<tt> [static]</tt></h3>
<p>Returns a listing of all the network interfaces found on the host machine.</p>
<!-- @@@allInterfaces -->
<!-- $$$flags[overload1]$$$flags -->
<h3 class="fn"><a name="flags"></a><span class="type"><a href="qnetworkinterface.html#InterfaceFlag-enum">InterfaceFlags</a></span> QNetworkInterface::<span class="name">flags</span> () const</h3>
<p>Returns the flags associated with this network interface.</p>
<!-- @@@flags -->
<!-- $$$hardwareAddress[overload1]$$$hardwareAddress -->
<h3 class="fn"><a name="hardwareAddress"></a><span class="type"><a href="qstring.html">QString</a></span> QNetworkInterface::<span class="name">hardwareAddress</span> () const</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>
<!-- @@@hardwareAddress -->
<!-- $$$humanReadableName[overload1]$$$humanReadableName -->
<h3 class="fn"><a name="humanReadableName"></a><span class="type"><a href="qstring.html">QString</a></span> QNetworkInterface::<span class="name">humanReadableName</span> () const</h3>
<p>Returns the human-readable name of this network interface on Windows, such as &quot;Local Area Connection&quot;, 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>
<!-- @@@humanReadableName -->
<!-- $$$index[overload1]$$$index -->
<h3 class="fn"><a name="index"></a><span class="type">int</span> QNetworkInterface::<span class="name">index</span> () const</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>
<!-- @@@index -->
<!-- $$$interfaceFromIndex[overload1]$$$interfaceFromIndexint -->
<h3 class="fn"><a name="interfaceFromIndex"></a><span class="type">QNetworkInterface</span> QNetworkInterface::<span class="name">interfaceFromIndex</span> ( <span class="type">int</span> <i>index</i> )<tt> [static]</tt></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 &quot;interface index&quot; 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>
<!-- @@@interfaceFromIndex -->
<!-- $$$interfaceFromName[overload1]$$$interfaceFromNameconstQString& -->
<h3 class="fn"><a name="interfaceFromName"></a><span class="type">QNetworkInterface</span> QNetworkInterface::<span class="name">interfaceFromName</span> ( const <span class="type"><a href="qstring.html">QString</a></span> &amp; <i>name</i> )<tt> [static]</tt></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>
<!-- @@@interfaceFromName -->
<!-- $$$isValid[overload1]$$$isValid -->
<h3 class="fn"><a name="isValid"></a><span class="type">bool</span> QNetworkInterface::<span class="name">isValid</span> () const</h3>
<p>Returns true if this <a href="qnetworkinterface.html">QNetworkInterface</a> object contains valid information about a network interface.</p>
<!-- @@@isValid -->
<!-- $$$name[overload1]$$$name -->
<h3 class="fn"><a name="name"></a><span class="type"><a href="qstring.html">QString</a></span> QNetworkInterface::<span class="name">name</span> () const</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 &quot;eth0&quot;, &quot;lo&quot; or &quot;pcn0&quot;. On Windows, it's an internal ID that cannot be changed by the user.</p>
<!-- @@@name -->
<!-- $$$operator=[overload1]$$$operator=constQNetworkInterface& -->
<h3 class="fn"><a name="operator-eq"></a><span class="type">QNetworkInterface</span> &amp; QNetworkInterface::<span class="name">operator=</span> ( const <span class="type">QNetworkInterface</span> &amp; <i>other</i> )</h3>
<p>Copies the contents of the <a href="qnetworkinterface.html">QNetworkInterface</a> object contained in <i>other</i> into this one.</p>
<!-- @@@operator= -->
</div>
  <div class="ft">
    <span></span>
  </div>
</div> 
<div class="footer">
    <p>
      <acronym title="Copyright">&copy;</acronym> 2012 Nokia Corporation and/or its
      subsidiaries. Documentation contributions included herein are the copyrights of
      their respective owners.</p>
    <br />
    <p>
      The documentation provided herein is licensed under the terms of the
      <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation
      License version 1.3</a> as published by the Free Software Foundation.</p>
    <p>
      Documentation sources may be obtained from <a href="http://www.qt-project.org">
      www.qt-project.org</a>.</p>
    <br />
    <p>
      Nokia, Qt and their respective logos are trademarks of Nokia Corporation 
      in Finland and/or other countries worldwide. All other trademarks are property
      of their respective owners. <a title="Privacy Policy"
      href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
</div>
</body>
</html>