[190] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
| 2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/network/qhostaddress.cpp:82 -->
|
---|
| 3 | <html>
|
---|
| 4 | <head>
|
---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
| 6 | <title>QHostAddress Class</title>
|
---|
| 7 | <style type="text/css"><!--
|
---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
| 9 | a:link { color: #004faf; text-decoration: none }
|
---|
| 10 | a:visited { color: #672967; text-decoration: none }
|
---|
| 11 | body { background: #ffffff; color: black; }
|
---|
| 12 | --></style>
|
---|
| 13 | </head>
|
---|
| 14 | <body>
|
---|
| 15 |
|
---|
| 16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
| 17 | <tr bgcolor="#E5E5E5">
|
---|
| 18 | <td valign=center>
|
---|
| 19 | <a href="index.html">
|
---|
| 20 | <font color="#004faf">Home</font></a>
|
---|
| 21 | | <a href="classes.html">
|
---|
| 22 | <font color="#004faf">All Classes</font></a>
|
---|
| 23 | | <a href="mainclasses.html">
|
---|
| 24 | <font color="#004faf">Main Classes</font></a>
|
---|
| 25 | | <a href="annotated.html">
|
---|
| 26 | <font color="#004faf">Annotated</font></a>
|
---|
| 27 | | <a href="groups.html">
|
---|
| 28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
| 29 | | <a href="functions.html">
|
---|
| 30 | <font color="#004faf">Functions</font></a>
|
---|
| 31 | </td>
|
---|
| 32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QHostAddress Class Reference<br><small>[<a href="network.html">network module</a>]</small></h1>
|
---|
| 33 |
|
---|
| 34 | <p>The QHostAddress class provides an IP address.
|
---|
| 35 | <a href="#details">More...</a>
|
---|
| 36 | <p><tt>#include <<a href="qhostaddress-h.html">qhostaddress.h</a>></tt>
|
---|
| 37 | <p><a href="qhostaddress-members.html">List of all member functions.</a>
|
---|
| 38 | <h2>Public Members</h2>
|
---|
| 39 | <ul>
|
---|
| 40 | <li class=fn><a href="#QHostAddress"><b>QHostAddress</b></a> ()</li>
|
---|
| 41 | <li class=fn><a href="#QHostAddress-2"><b>QHostAddress</b></a> ( Q_UINT32 ip4Addr )</li>
|
---|
| 42 | <li class=fn><a href="#QHostAddress-3"><b>QHostAddress</b></a> ( Q_UINT8 * ip6Addr )</li>
|
---|
| 43 | <li class=fn><a href="#QHostAddress-4"><b>QHostAddress</b></a> ( const Q_IPV6ADDR & ip6Addr )</li>
|
---|
| 44 | <li class=fn><a href="#QHostAddress-6"><b>QHostAddress</b></a> ( const QHostAddress & address )</li>
|
---|
| 45 | <li class=fn>virtual <a href="#~QHostAddress"><b>~QHostAddress</b></a> ()</li>
|
---|
| 46 | <li class=fn>QHostAddress & <a href="#operator-eq"><b>operator=</b></a> ( const QHostAddress & address )</li>
|
---|
| 47 | <li class=fn>void <a href="#setAddress"><b>setAddress</b></a> ( Q_UINT32 ip4Addr )</li>
|
---|
| 48 | <li class=fn>void <a href="#setAddress-2"><b>setAddress</b></a> ( Q_UINT8 * ip6Addr )</li>
|
---|
| 49 | <li class=fn>bool <a href="#setAddress-3"><b>setAddress</b></a> ( const QString & address )</li>
|
---|
| 50 | <li class=fn>bool isIp4Addr () const <em>(obsolete)</em></li>
|
---|
| 51 | <li class=fn>Q_UINT32 ip4Addr () const <em>(obsolete)</em></li>
|
---|
| 52 | <li class=fn>bool <a href="#isIPv4Address"><b>isIPv4Address</b></a> () const</li>
|
---|
| 53 | <li class=fn>Q_UINT32 <a href="#toIPv4Address"><b>toIPv4Address</b></a> () const</li>
|
---|
| 54 | <li class=fn>bool <a href="#isIPv6Address"><b>isIPv6Address</b></a> () const</li>
|
---|
| 55 | <li class=fn>Q_IPV6ADDR <a href="#toIPv6Address"><b>toIPv6Address</b></a> () const</li>
|
---|
| 56 | <li class=fn>QString <a href="#toString"><b>toString</b></a> () const</li>
|
---|
| 57 | <li class=fn>bool <a href="#operator-eq-eq"><b>operator==</b></a> ( const QHostAddress & other ) const</li>
|
---|
| 58 | <li class=fn>bool <a href="#isNull"><b>isNull</b></a> () const</li>
|
---|
| 59 | </ul>
|
---|
| 60 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
| 61 |
|
---|
| 62 |
|
---|
| 63 | The QHostAddress class provides an IP address.
|
---|
| 64 |
|
---|
| 65 | <p>
|
---|
| 66 |
|
---|
| 67 | <p> This class contains an IP address in a platform and protocol
|
---|
| 68 | independent manner. It stores both IPv4 and IPv6 addresses in a
|
---|
| 69 | way that you can easily access on any platform.
|
---|
| 70 | <p> QHostAddress is normally used with the classes <a href="qsocket.html">QSocket</a>,
|
---|
| 71 | <a href="qserversocket.html">QServerSocket</a> and <a href="qsocketdevice.html">QSocketDevice</a> to set up a server or to connect
|
---|
| 72 | to a host.
|
---|
| 73 | <p> Host addresses may be set with <a href="#setAddress">setAddress</a>() and retrieved with
|
---|
| 74 | <a href="#ip4Addr">ip4Addr</a>() or <a href="#toString">toString</a>().
|
---|
| 75 | <p> <p>See also <a href="qsocket.html">QSocket</a>, <a href="qserversocket.html">QServerSocket</a>, <a href="qsocketdevice.html">QSocketDevice</a>, and <a href="io.html">Input/Output and Networking</a>.
|
---|
| 76 |
|
---|
| 77 | <hr><h2>Member Function Documentation</h2>
|
---|
| 78 | <h3 class=fn><a name="QHostAddress"></a>QHostAddress::QHostAddress ()
|
---|
| 79 | </h3>
|
---|
| 80 | Creates a host address object with the IP address 0.0.0.0.
|
---|
| 81 |
|
---|
| 82 | <h3 class=fn><a name="QHostAddress-2"></a>QHostAddress::QHostAddress ( Q_UINT32 ip4Addr )
|
---|
| 83 | </h3>
|
---|
| 84 | Creates a host address object for the IPv4 address <em>ip4Addr</em>.
|
---|
| 85 |
|
---|
| 86 | <h3 class=fn><a name="QHostAddress-3"></a>QHostAddress::QHostAddress ( Q_UINT8 * ip6Addr )
|
---|
| 87 | </h3>
|
---|
| 88 | Creates a host address object with the specified IPv6 address.
|
---|
| 89 | <p> <em>ip6Addr</em> must be a 16 byte array in network byte order
|
---|
| 90 | (high-order byte first).
|
---|
| 91 |
|
---|
| 92 | <h3 class=fn><a name="QHostAddress-4"></a>QHostAddress::QHostAddress ( const Q_IPV6ADDR & ip6Addr )
|
---|
| 93 | </h3>
|
---|
| 94 | Creates a host address object with the IPv6 address, <em>ip6Addr</em>.
|
---|
| 95 |
|
---|
| 96 | <h3 class=fn><a name="QHostAddress-6"></a>QHostAddress::QHostAddress ( const <a href="qhostaddress.html">QHostAddress</a> & address )
|
---|
| 97 | </h3>
|
---|
| 98 | Creates a copy of <em>address</em>.
|
---|
| 99 |
|
---|
| 100 | <h3 class=fn><a name="~QHostAddress"></a>QHostAddress::~QHostAddress ()<tt> [virtual]</tt>
|
---|
| 101 | </h3>
|
---|
| 102 | Destroys the host address object.
|
---|
| 103 |
|
---|
| 104 | <h3 class=fn>Q_UINT32 <a name="ip4Addr"></a>QHostAddress::ip4Addr () const
|
---|
| 105 | </h3>
|
---|
| 106 | <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
| 107 | <p> Use <a href="#toIPv4Address">toIPv4Address</a>() instead.
|
---|
| 108 |
|
---|
| 109 | <h3 class=fn>bool <a name="isIPv4Address"></a>QHostAddress::isIPv4Address () const
|
---|
| 110 | </h3>
|
---|
| 111 | Returns TRUE if the host address represents an IPv4 address;
|
---|
| 112 | otherwise returns FALSE.
|
---|
| 113 |
|
---|
| 114 | <h3 class=fn>bool <a name="isIPv6Address"></a>QHostAddress::isIPv6Address () const
|
---|
| 115 | </h3>
|
---|
| 116 | Returns TRUE if the host address represents an IPv6 address;
|
---|
| 117 | otherwise returns FALSE.
|
---|
| 118 |
|
---|
| 119 | <h3 class=fn>bool <a name="isIp4Addr"></a>QHostAddress::isIp4Addr () const
|
---|
| 120 | </h3>
|
---|
| 121 | <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
| 122 | <p> Use <a href="#isIPv4Address">isIPv4Address</a>() instead.
|
---|
| 123 |
|
---|
| 124 | <h3 class=fn>bool <a name="isNull"></a>QHostAddress::isNull () const
|
---|
| 125 | </h3>
|
---|
| 126 | Returns TRUE if this host address is null (INADDR_ANY or in6addr_any). The
|
---|
| 127 | default constructor creates a null address, and that address isn't valid
|
---|
| 128 | for any particular host or interface.
|
---|
| 129 |
|
---|
| 130 | <h3 class=fn><a href="qhostaddress.html">QHostAddress</a> & <a name="operator-eq"></a>QHostAddress::operator= ( const <a href="qhostaddress.html">QHostAddress</a> & address )
|
---|
| 131 | </h3>
|
---|
| 132 | Assigns another host address object <em>address</em> to this object and
|
---|
| 133 | returns a reference to this object.
|
---|
| 134 |
|
---|
| 135 | <h3 class=fn>bool <a name="operator-eq-eq"></a>QHostAddress::operator== ( const <a href="qhostaddress.html">QHostAddress</a> & other ) const
|
---|
| 136 | </h3>
|
---|
| 137 | Returns TRUE if this host address is the same as <em>other</em>;
|
---|
| 138 | otherwise returns FALSE.
|
---|
| 139 |
|
---|
| 140 | <h3 class=fn>void <a name="setAddress"></a>QHostAddress::setAddress ( Q_UINT32 ip4Addr )
|
---|
| 141 | </h3>
|
---|
| 142 | Set the IPv4 address specified by <em>ip4Addr</em>.
|
---|
| 143 |
|
---|
| 144 | <h3 class=fn>void <a name="setAddress-2"></a>QHostAddress::setAddress ( Q_UINT8 * ip6Addr )
|
---|
| 145 | </h3>
|
---|
| 146 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 147 | <p> Set the IPv6 address specified by <em>ip6Addr</em>.
|
---|
| 148 | <p> <em>ip6Addr</em> must be a 16 byte array in network byte order
|
---|
| 149 | (high-order byte first).
|
---|
| 150 |
|
---|
| 151 | <h3 class=fn>bool <a name="setAddress-3"></a>QHostAddress::setAddress ( const <a href="qstring.html">QString</a> & address )
|
---|
| 152 | </h3>
|
---|
| 153 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 154 | <p> Sets the IPv4 or IPv6 address specified by the string
|
---|
| 155 | representation <em>address</em> (e.g. "127.0.0.1"). Returns TRUE and
|
---|
| 156 | sets the address if the address was successfully parsed; otherwise
|
---|
| 157 | returns FALSE and leaves the address unchanged.
|
---|
| 158 |
|
---|
| 159 | <h3 class=fn>Q_UINT32 <a name="toIPv4Address"></a>QHostAddress::toIPv4Address () const
|
---|
| 160 | </h3>
|
---|
| 161 | Returns the IPv4 address as a number.
|
---|
| 162 | <p> For example, if the address is 127.0.0.1, the returned value is
|
---|
| 163 | 2130706433 (i.e. 0x7f000001).
|
---|
| 164 | <p> This value is only valid when <a href="#isIp4Addr">isIp4Addr</a>() returns TRUE.
|
---|
| 165 | <p> <p>See also <a href="#toString">toString</a>().
|
---|
| 166 |
|
---|
| 167 | <h3 class=fn>Q_IPV6ADDR <a name="toIPv6Address"></a>QHostAddress::toIPv6Address () const
|
---|
| 168 | </h3>
|
---|
| 169 | Returns the IPv6 address as a Q_IPV6ADDR structure. The structure
|
---|
| 170 | consists of 16 unsigned characters.
|
---|
| 171 | <p> <pre>
|
---|
| 172 | Q_IPV6ADDR addr = hostAddr.ip6Addr();
|
---|
| 173 | // addr.c[] contains 16 unsigned characters
|
---|
| 174 |
|
---|
| 175 | for (int i = 0; i < 16; ++i) {
|
---|
| 176 | // process addr.c[i]
|
---|
| 177 | }
|
---|
| 178 | </pre>
|
---|
| 179 |
|
---|
| 180 | <p> This value is only valid when <a href="#isIPv6Address">isIPv6Address</a>() returns TRUE.
|
---|
| 181 | <p> <p>See also <a href="#toString">toString</a>().
|
---|
| 182 |
|
---|
| 183 | <h3 class=fn><a href="qstring.html">QString</a> <a name="toString"></a>QHostAddress::toString () const
|
---|
| 184 | </h3>
|
---|
| 185 | Returns the address as a string.
|
---|
| 186 | <p> For example, if the address is the IPv4 address 127.0.0.1, the
|
---|
| 187 | returned string is "127.0.0.1".
|
---|
| 188 | <p> <p>See also <a href="#ip4Addr">ip4Addr</a>().
|
---|
| 189 |
|
---|
| 190 | <!-- eof -->
|
---|
| 191 | <hr><p>
|
---|
| 192 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
| 193 | Copyright © 1995-2007
|
---|
| 194 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
---|
| 195 | <table width=100% cellspacing=0 border=0><tr>
|
---|
| 196 | <td>Copyright © 2007
|
---|
| 197 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
| 198 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
| 199 | </table></div></address></body>
|
---|
| 200 | </html>
|
---|