~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/qhostaddress.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/src/network/qhostaddress.cpp -->
 
6
<head>
 
7
    <title>Qt 4.0: QHostAddress Class Reference</title>
 
8
    <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
 
9
a:link { color: #004faf; text-decoration: none }
 
10
a:visited { color: #672967; text-decoration: none }
 
11
td.postheader { font-family: sans-serif }
 
12
tr.address { font-family: sans-serif }
 
13
body { background: #ffffff; color: black; }</style>
 
14
</head>
 
15
<body>
 
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
17
<tr>
 
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
 
19
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
 
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">QHostAddress Class Reference</h1>
 
21
<p>The QHostAddress class provides an IP address. <a href="#details">More...</a></p>
 
22
<pre>#include &lt;QHostAddress&gt;</pre><p>Part of the <a href="qtnetwork.html">QtNetwork</a> module.</p>
 
23
<ul>
 
24
<li><a href="qhostaddress-members.html">List of all members, including inherited members</a></li>
 
25
<li><a href="qhostaddress-qt3.html">Qt 3 support members</a></li>
 
26
</ul>
 
27
<a name="public-types"></a>
 
28
<h3>Public Types</h3>
 
29
<ul>
 
30
<li><div class="fn"/>enum <b><a href="qhostaddress.html#SpecialAddress-enum">SpecialAddress</a></b> { Null, LocalHost, LocalHostIPv6, Broadcast, Any, AnyIPv6 }</li>
 
31
</ul>
 
32
<a name="public-functions"></a>
 
33
<h3>Public Functions</h3>
 
34
<ul>
 
35
<li><div class="fn"/><b><a href="qhostaddress.html#QHostAddress">QHostAddress</a></b> ()</li>
 
36
<li><div class="fn"/><b><a href="qhostaddress.html#QHostAddress-2">QHostAddress</a></b> ( quint32 <i>ip4Addr</i> )</li>
 
37
<li><div class="fn"/><b><a href="qhostaddress.html#QHostAddress-3">QHostAddress</a></b> ( quint8 * <i>ip6Addr</i> )</li>
 
38
<li><div class="fn"/><b><a href="qhostaddress.html#QHostAddress-4">QHostAddress</a></b> ( const Q_IPV6ADDR &amp; <i>ip6Addr</i> )</li>
 
39
<li><div class="fn"/><b><a href="qhostaddress.html#QHostAddress-5">QHostAddress</a></b> ( const QString &amp; <i>address</i> )</li>
 
40
<li><div class="fn"/><b><a href="qhostaddress.html#QHostAddress-6">QHostAddress</a></b> ( const QHostAddress &amp; <i>address</i> )</li>
 
41
<li><div class="fn"/><b><a href="qhostaddress.html#QHostAddress-7">QHostAddress</a></b> ( SpecialAddress <i>address</i> )</li>
 
42
<li><div class="fn"/><b><a href="qhostaddress.html#dtor.QHostAddress">~QHostAddress</a></b> ()</li>
 
43
<li><div class="fn"/>void <b><a href="qhostaddress.html#clear">clear</a></b> ()</li>
 
44
<li><div class="fn"/>bool <b><a href="qhostaddress.html#isNull">isNull</a></b> () const</li>
 
45
<li><div class="fn"/>QAbstractSocket::NetworkLayerProtocol <b><a href="qhostaddress.html#protocol">protocol</a></b> () const</li>
 
46
<li><div class="fn"/>void <b><a href="qhostaddress.html#setAddress">setAddress</a></b> ( quint32 <i>ip4Addr</i> )</li>
 
47
<li><div class="fn"/>void <b><a href="qhostaddress.html#setAddress-2">setAddress</a></b> ( quint8 * <i>ip6Addr</i> )</li>
 
48
<li><div class="fn"/>void <b><a href="qhostaddress.html#setAddress-3">setAddress</a></b> ( const Q_IPV6ADDR &amp; <i>ip6Addr</i> )</li>
 
49
<li><div class="fn"/>bool <b><a href="qhostaddress.html#setAddress-4">setAddress</a></b> ( const QString &amp; <i>address</i> )</li>
 
50
<li><div class="fn"/>quint32 <b><a href="qhostaddress.html#toIPv4Address">toIPv4Address</a></b> () const</li>
 
51
<li><div class="fn"/>Q_IPV6ADDR <b><a href="qhostaddress.html#toIPv6Address">toIPv6Address</a></b> () const</li>
 
52
<li><div class="fn"/>QString <b><a href="qhostaddress.html#toString">toString</a></b> () const</li>
 
53
<li><div class="fn"/>QHostAddress &amp; <b><a href="qhostaddress.html#operator-eq">operator=</a></b> ( const QHostAddress &amp; <i>address</i> )</li>
 
54
<li><div class="fn"/>bool <b><a href="qhostaddress.html#operator-eq-eq">operator==</a></b> ( const QHostAddress &amp; <i>other</i> ) const</li>
 
55
<li><div class="fn"/>bool <b><a href="qhostaddress.html#operator-eq-eq-2">operator==</a></b> ( SpecialAddress <i>other</i> ) const</li>
 
56
</ul>
 
57
<a name="details"></a>
 
58
<hr />
 
59
<h2>Detailed Description</h2>
 
60
<p>The QHostAddress class provides an IP address.</p>
 
61
<p>This class holds an IPv4 or IPv6 address in a platform- and protocol-independent manner.</p>
 
62
<p>QHostAddress is normally used with the <a href="qtcpsocket.html">QTcpSocket</a>, <a href="qtcpserver.html">QTcpServer</a>, and <a href="qudpsocket.html">QUdpSocket</a> to connect to a host or to set up a server.</p>
 
63
<p>A host address is set with <a href="qhostaddress.html#setAddress">setAddress</a>(), checked for its type using <a href="qhostaddress-qt3.html#isIPv4Address">isIPv4Address</a>() or <a href="qhostaddress-qt3.html#isIPv6Address">isIPv6Address</a>(), and retrieved with <a href="qhostaddress.html#toIPv4Address">toIPv4Address</a>(), <a href="qhostaddress.html#toIPv6Address">toIPv6Address</a>(), or <a href="qhostaddress.html#toString">toString</a>().</p>
 
64
<p>The class also supports common predefined addresses: <a href="qhostaddress.html#SpecialAddress-enum">Null</a>, <a href="qhostaddress.html#SpecialAddress-enum">LocalHost</a>, <a href="qhostaddress.html#SpecialAddress-enum">LocalHostIPv6</a>, <a href="qhostaddress.html#SpecialAddress-enum">Broadcast</a>, and <a href="qhostaddress.html#SpecialAddress-enum">Any</a>.</p>
 
65
<p>See also <a href="qtcpsocket.html">QTcpSocket</a>, <a href="qtcpserver.html">QTcpServer</a>, and <a href="qudpsocket.html">QUdpSocket</a>.</p>
 
66
<hr />
 
67
<h2>Member Type Documentation</h2>
 
68
<h3 class="fn"><a name="SpecialAddress-enum"></a>enum QHostAddress::SpecialAddress</h3>
 
69
<table border="1" cellpadding="2" cellspacing="1" width="100%">
 
70
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
 
71
<tr><td valign="top"><tt>QHostAddress::Null</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">The null address object. Equivalent to <a href="qhostaddress.html#QHostAddress">QHostAddress</a>().</td></tr>
 
72
<tr><td valign="top"><tt>QHostAddress::LocalHost</tt></td><td align="center" valign="top"><tt>2</tt></td><td valign="top">The IPv4 localhost address. Equivalent to <a href="qhostaddress.html">QHostAddress</a>(&quot;127.0.0.1&quot;).</td></tr>
 
73
<tr><td valign="top"><tt>QHostAddress::LocalHostIPv6</tt></td><td align="center" valign="top"><tt>3</tt></td><td valign="top">The IPv6 localhost address. Equivalent to <a href="qhostaddress.html">QHostAddress</a>(&quot;::1&quot;).</td></tr>
 
74
<tr><td valign="top"><tt>QHostAddress::Broadcast</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top">The IPv4 broadcast address. Equivalent to <a href="qhostaddress.html">QHostAddress</a>(&quot;255.255.255.255&quot;).</td></tr>
 
75
<tr><td valign="top"><tt>QHostAddress::Any</tt></td><td align="center" valign="top"><tt>4</tt></td><td valign="top">The IPv4 any-address. Equivalent to <a href="qhostaddress.html">QHostAddress</a>(&quot;0.0.0.0&quot;).</td></tr>
 
76
<tr><td valign="top"><tt>QHostAddress::AnyIPv6</tt></td><td align="center" valign="top"><tt>5</tt></td><td valign="top">The IPv6 any-address. Equivalent to <a href="qhostaddress.html">QHostAddress</a>(&quot;::&quot;).</td></tr>
 
77
</table>
 
78
<hr />
 
79
<h2>Member Function Documentation</h2>
 
80
<h3 class="fn"><a name="QHostAddress"></a>QHostAddress::QHostAddress ()</h3>
 
81
<p>Constructs a host address object with the IP address 0.0.0.0.</p>
 
82
<p>See also <a href="qhostaddress.html#clear">clear</a>().</p>
 
83
<h3 class="fn"><a name="QHostAddress-2"></a>QHostAddress::QHostAddress ( <a href="qtglobal.html#quint32-typedef">quint32</a> <i>ip4Addr</i> )</h3>
 
84
<p>Constructs a host address object with the IPv4 address <i>ip4Addr</i>.</p>
 
85
<h3 class="fn"><a name="QHostAddress-3"></a>QHostAddress::QHostAddress ( <a href="qtglobal.html#quint8-typedef">quint8</a> * <i>ip6Addr</i> )</h3>
 
86
<p>Constructs a host address object with the IPv6 address <i>ip6Addr</i>.</p>
 
87
<p><i>ip6Addr</i> must be a 16-byte array in network byte order (big endian).</p>
 
88
<h3 class="fn"><a name="QHostAddress-4"></a>QHostAddress::QHostAddress ( const Q_IPV6ADDR &amp; <i>ip6Addr</i> )</h3>
 
89
<p>Constructs a host address object with the IPv6 address <i>ip6Addr</i>.</p>
 
90
<h3 class="fn"><a name="QHostAddress-5"></a>QHostAddress::QHostAddress ( const <a href="qstring.html">QString</a> &amp; <i>address</i> )</h3>
 
91
<p>Constructs an IPv4 or IPv6 address based on the string <i>address</i> (e.g., &quot;127.0.0.1&quot;).</p>
 
92
<p>See also <a href="qhostaddress.html#setAddress">setAddress</a>().</p>
 
93
<h3 class="fn"><a name="QHostAddress-6"></a>QHostAddress::QHostAddress ( const QHostAddress &amp; <i>address</i> )</h3>
 
94
<p>Constructs a copy of the given <i>address</i>.</p>
 
95
<h3 class="fn"><a name="QHostAddress-7"></a>QHostAddress::QHostAddress ( <a href="qhostaddress.html#SpecialAddress-enum">SpecialAddress</a> <i>address</i> )</h3>
 
96
<p>Constructs a <a href="qhostaddress.html">QHostAddress</a> object for <i>address</i>.</p>
 
97
<h3 class="fn"><a name="dtor.QHostAddress"></a>QHostAddress::~QHostAddress ()</h3>
 
98
<p>Destroys the host address object.</p>
 
99
<h3 class="fn"><a name="clear"></a>void QHostAddress::clear ()</h3>
 
100
<p>Sets the host address to 0.0.0.0.</p>
 
101
<h3 class="fn"><a name="isNull"></a>bool QHostAddress::isNull () const</h3>
 
102
<p>Returns true if this host address is null (INADDR_ANY or in6addr_any). The default constructor creates a null address, and that address is not valid for any host or interface.</p>
 
103
<h3 class="fn"><a name="protocol"></a><a href="qabstractsocket.html#NetworkLayerProtocol-enum">QAbstractSocket::NetworkLayerProtocol</a> QHostAddress::protocol () const</h3>
 
104
<p>Returns the network layer protocol of the host address.</p>
 
105
<h3 class="fn"><a name="setAddress"></a>void QHostAddress::setAddress ( <a href="qtglobal.html#quint32-typedef">quint32</a> <i>ip4Addr</i> )</h3>
 
106
<p>Set the IPv4 address specified by <i>ip4Addr</i>.</p>
 
107
<h3 class="fn"><a name="setAddress-2"></a>void QHostAddress::setAddress ( <a href="qtglobal.html#quint8-typedef">quint8</a> * <i>ip6Addr</i> )</h3>
 
108
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
109
<p>Set the IPv6 address specified by <i>ip6Addr</i>.</p>
 
110
<p><i>ip6Addr</i> must be an array of 16 bytes in network byte order (high-order byte first).</p>
 
111
<h3 class="fn"><a name="setAddress-3"></a>void QHostAddress::setAddress ( const Q_IPV6ADDR &amp; <i>ip6Addr</i> )</h3>
 
112
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
113
<p>Set the IPv6 address specified by <i>ip6Addr</i>.</p>
 
114
<h3 class="fn"><a name="setAddress-4"></a>bool QHostAddress::setAddress ( const <a href="qstring.html">QString</a> &amp; <i>address</i> )</h3>
 
115
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
116
<p>Sets the IPv4 or IPv6 address specified by the string representation specified by <i>address</i> (e.g. &quot;127.0.0.1&quot;). Returns true and sets the address if the address was successfully parsed; otherwise returns false.</p>
 
117
<h3 class="fn"><a name="toIPv4Address"></a><a href="qtglobal.html#quint32-typedef">quint32</a> QHostAddress::toIPv4Address () const</h3>
 
118
<p>Returns the IPv4 address as a number.</p>
 
119
<p>For example, if the address is 127.0.0.1, the returned value is 2130706433 (i.e. 0x7f000001).</p>
 
120
<p>This value is only valid if <a href="qhostaddress-qt3.html#isIp4Addr">isIp4Addr</a>() returns true.</p>
 
121
<p>See also <a href="qhostaddress.html#toString">toString</a>().</p>
 
122
<h3 class="fn"><a name="toIPv6Address"></a>Q_IPV6ADDR QHostAddress::toIPv6Address () const</h3>
 
123
<p>Returns the IPv6 address as a Q_IPV6ADDR structure. The structure consists of 16 unsigned characters.</p>
 
124
<pre>&nbsp;   Q_IPV6ADDR addr = hostAddr.ip6Addr();
 
125
    // addr contains 16 unsigned characters
 
126
 
 
127
    for (int i = 0; i &lt; 16; ++i) {
 
128
        // process addr[i]
 
129
    }</pre>
 
130
<p>This value is only valid if <a href="qhostaddress-qt3.html#isIPv6Address">isIPv6Address</a>() returns true.</p>
 
131
<p>See also <a href="qhostaddress.html#toString">toString</a>().</p>
 
132
<h3 class="fn"><a name="toString"></a><a href="qstring.html">QString</a> QHostAddress::toString () const</h3>
 
133
<p>Returns the address as a string.</p>
 
134
<p>For example, if the address is the IPv4 address 127.0.0.1, the returned string is &quot;127.0.0.1&quot;.</p>
 
135
<p>See also <a href="qhostaddress.html#toIPv4Address">toIPv4Address</a>().</p>
 
136
<h3 class="fn"><a name="operator-eq"></a>QHostAddress &amp; QHostAddress::operator= ( const QHostAddress &amp; <i>address</i> )</h3>
 
137
<p>Assigns another host <i>address</i> to this object, and returns a reference to this object.</p>
 
138
<h3 class="fn"><a name="operator-eq-eq"></a>bool QHostAddress::operator== ( const QHostAddress &amp; <i>other</i> ) const</h3>
 
139
<p>Returns true if this host address is the same as the <i>other</i> address given; otherwise returns false.</p>
 
140
<h3 class="fn"><a name="operator-eq-eq-2"></a>bool QHostAddress::operator== ( <a href="qhostaddress.html#SpecialAddress-enum">SpecialAddress</a> <i>other</i> ) const</h3>
 
141
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
142
<p>Returns true if this host address is the same as the <i>other</i> address given; otherwise returns false.</p>
 
143
<p /><address><hr /><div align="center">
 
144
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
145
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
146
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
147
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
148
</tr></table></div></address></body>
 
149
</html>