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
|
<?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>QHostAddress 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="../pyqt4ref.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">QHostAddress Class Reference<br /><sup><sup>[<a href="qtnetwork.html">QtNetwork</a> module]</sup></sup></h1><p>The QHostAddress class provides an IP address. <a href="#details">More...</a></p>
<h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qhostaddress.html#SpecialAddress-enum">SpecialAddress</a></b> { Null, Broadcast, LocalHost, LocalHostIPv6, Any, AnyIPv6 }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qhostaddress.html#QHostAddress">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qhostaddress.html#QHostAddress-2">__init__</a></b> (<i>self</i>, SpecialAddress <i>address</i>)</li><li><div class="fn" /><b><a href="qhostaddress.html#QHostAddress-3">__init__</a></b> (<i>self</i>, unsigned long <i>ip4Addr</i>)</li><li><div class="fn" /><b><a href="qhostaddress.html#QHostAddress-4">__init__</a></b> (<i>self</i>, QString <i>address</i>)</li><li><div class="fn" /><b><a href="qhostaddress.html#QHostAddress-5">__init__</a></b> (<i>self</i>, QHostAddress <i>copy</i>)</li><li><div class="fn" /><b><a href="qhostaddress.html#clear">clear</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qhostaddress.html#isNull">isNull</a></b> (<i>self</i>)</li><li><div class="fn" />QAbstractSocket.NetworkLayerProtocol <b><a href="qhostaddress.html#protocol">protocol</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qhostaddress.html#scopeId">scopeId</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qhostaddress.html#setAddress">setAddress</a></b> (<i>self</i>, unsigned long <i>ip4Addr</i>)</li><li><div class="fn" />bool <b><a href="qhostaddress.html#setAddress-2">setAddress</a></b> (<i>self</i>, QString <i>address</i>)</li><li><div class="fn" /><b><a href="qhostaddress.html#setScopeId">setScopeId</a></b> (<i>self</i>, QString <i>id</i>)</li><li><div class="fn" />unsigned long <b><a href="qhostaddress.html#toIPv4Address">toIPv4Address</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qhostaddress.html#toString">toString</a></b> (<i>self</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />bool <b><a href="qhostaddress.html#__eq__">__eq__</a></b> (<i>self</i>, QHostAddress <i>address</i>)</li><li><div class="fn" />bool <b><a href="qhostaddress.html#__eq__-2">__eq__</a></b> (<i>self</i>, SpecialAddress <i>address</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QHostAddress class provides an IP address.</p>
<p>This class holds an IPv4 or IPv6 address in a platform- and protocol-independent manner.</p>
<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>
<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>
<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>
<p>See also <a href="qtcpsocket.html">QTcpSocket</a>, <a href="qtcpserver.html">QTcpServer</a>, and <a href="qudpsocket.html">QUdpSocket</a>.</p>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="SpecialAddress-enum" />QHostAddress.SpecialAddress</h3><table border="1" cellpadding="2" cellspacing="1" width="100%">
<tr>
<th width="25%">Constant</th>
<th width="15%">Value</th>
<th width="60%">Description</th>
</tr>
<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>
<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>("127.0.0.1").</td>
</tr>
<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>(".1").</td>
</tr>
<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>("255.255.255.255").</td>
</tr>
<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>("0.0.0.0").</td>
</tr>
<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>(".").</td>
</tr>
</table>
<br />
<br />
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QHostAddress" />QHostAddress.__init__ (<i>self</i>)</h3><p>Constructs a host address object with the IP address 0.0.0.0.</p>
<p>See also <a href="qhostaddress.html#clear">clear</a>().</p>
<h3 class="fn"><a name="QHostAddress-2" />QHostAddress.__init__ (<i>self</i>, <a href="qhostaddress.html#SpecialAddress-enum">SpecialAddress</a> <i>address</i>)</h3><p>Constructs a host address object with the IPv4 address <i>ip4Addr</i>.</p>
<h3 class="fn"><a name="QHostAddress-3" />QHostAddress.__init__ (<i>self</i>, unsigned long <i>ip4Addr</i>)</h3><p>Constructs a host address object with the IPv6 address <i>ip6Addr</i>.</p>
<p><i>ip6Addr</i> must be a 16-byte array in network byte order (big endian).</p>
<h3 class="fn"><a name="QHostAddress-4" />QHostAddress.__init__ (<i>self</i>, <a href="qstring.html">QString</a> <i>address</i>)</h3><p>Constructs a host address object with the IPv6 address <i>ip6Addr</i>.</p>
<h3 class="fn"><a name="QHostAddress-5" />QHostAddress.__init__ (<i>self</i>, <a href="qhostaddress.html">QHostAddress</a> <i>copy</i>)</h3><p>Constructs an IPv4 or IPv6 address using the address specified by the native structure <i>sockaddr</i>.</p>
<p>See also <a href="qhostaddress.html#setAddress">setAddress</a>().</p>
<h3 class="fn"><a name="clear" />QHostAddress.clear (<i>self</i>)</h3><p>Sets the host address to 0.0.0.0.</p>
<h3 class="fn"><a name="isNull" />bool QHostAddress.isNull (<i>self</i>)</h3><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>
<h3 class="fn"><a name="protocol" /><a href="qabstractsocket.html#NetworkLayerProtocol-enum">QAbstractSocket.NetworkLayerProtocol</a> QHostAddress.protocol (<i>self</i>)</h3><p>Returns the network layer protocol of the host address.</p>
<h3 class="fn"><a name="scopeId" /><a href="qstring.html">QString</a> QHostAddress.scopeId (<i>self</i>)</h3><p>Returns the scope ID of an IPv6 address. For IPv4 addresses, or if the address does not contain a scope ID, an empty <a href="qstring.html">QString</a> is returned.</p>
<p>The IPv6 scope ID specifies the scope of <i>reachability</i> for non-global IPv6 addresses, limiting the area in which the address can be used. All IPv6 addresses are associated with such a reachability scope. The scope ID is used to disambiguate addresses that are not guaranteed to be globally unique.</p>
<p>IPv6 specifies the following four levels of reachability:</p>
<ul>
<li>Node-local: Addresses that are only used for communicating with services on the same interface (e.g., the loopback interface ".1").</li>
<li>Link-local: Addresses that are local to the network interface (<i>link</i>). There is always one link-local address for each IPv6 interface on your host. Link-local addresses ("fe80...") are generated from the MAC address of the local network adaptor, and are not guaranteed to be unique.</li>
<li>Site-local: Addresses that are local to the site / private network (e.g., the company intranet). Site-local addresses ("fec0...") are usually distributed by the site router, and are not guaranteed to be unique outside of the local site.</li>
<li>Global: For globally routable addresses, such as public servers on the Internet.</li>
</ul>
<p>When using a link-local or site-local address for IPv6 connections, you must specify the scope ID. The scope ID for a link-local address is usually the same as the interface name (e.g., "eth0", "en1") or number (e.g., "1", "2").</p>
<p>This function was introduced in Qt 4.1.</p>
<p>See also <a href="qhostaddress.html#setScopeId">setScopeId</a>().</p>
<h3 class="fn"><a name="setAddress" />QHostAddress.setAddress (<i>self</i>, unsigned long <i>ip4Addr</i>)</h3><p>Set the IPv4 address specified by <i>ip4Addr</i>.</p>
<h3 class="fn"><a name="setAddress-2" />bool QHostAddress.setAddress (<i>self</i>, <a href="qstring.html">QString</a> <i>address</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Set the IPv6 address specified by <i>ip6Addr</i>.</p>
<p><i>ip6Addr</i> must be an array of 16 bytes in network byte order (high-order byte first).</p>
<h3 class="fn"><a name="setScopeId" />QHostAddress.setScopeId (<i>self</i>, <a href="qstring.html">QString</a> <i>id</i>)</h3><p>Sets the IPv6 scope ID of the address to <i>id</i>. If the address protocol is not IPv6, this function does nothing.</p>
<p>This function was introduced in Qt 4.1.</p>
<p>See also <a href="qhostaddress.html#scopeId">scopeId</a>().</p>
<h3 class="fn"><a name="toIPv4Address" />unsigned long QHostAddress.toIPv4Address (<i>self</i>)</h3><p>Returns the IPv4 address as a number.</p>
<p>For example, if the address is 127.0.0.1, the returned value is 2130706433 (i.e. 0x7f000001).</p>
<p>This value is only valid if <a href="qhostaddress-qt3.html#isIp4Addr">isIp4Addr</a>() returns true.</p>
<p>See also <a href="qhostaddress.html#toString">toString</a>().</p>
<h3 class="fn"><a name="toString" /><a href="qstring.html">QString</a> QHostAddress.toString (<i>self</i>)</h3><p>Returns the address as a string.</p>
<p>For example, if the address is the IPv4 address 127.0.0.1, the returned string is "127.0.0.1".</p>
<p>See also <a href="qhostaddress.html#toIPv4Address">toIPv4Address</a>().</p>
<h3 class="fn"><a name="__eq__" />bool QHostAddress.__eq__ (<i>self</i>, <a href="qhostaddress.html">QHostAddress</a> <i>address</i>)</h3><h3 class="fn"><a name="__eq__-2" />bool QHostAddress.__eq__ (<i>self</i>, <a href="qhostaddress.html#SpecialAddress-enum">SpecialAddress</a> <i>address</i>)</h3><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td width="25%">PyQt 4.0.1 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.trolltech.com">Trolltech AS</a> 2006</td><td align="right" width="25%">Qt 4.1.4</td></tr></table></div></address></body></html>
|