<class name="QHostInfo" doc="/** <p>The <a href="QHostInfo.html#QHostInfo(com.trolltech.qt.network.QHostInfo)"><tt>QHostInfo</tt></a> class provides static functions for host name lookups.</p> <p><a href="QHostInfo.html#QHostInfo(com.trolltech.qt.network.QHostInfo)"><tt>QHostInfo</tt></a> uses the lookup mechanisms provided by the operating system to find the IP address(es) associated with a host name, or the host name associated with an IP address. The class provides two static convenience functions: one that works asynchronously and emits a signal once the host is found, and one that blocks and returns a <a href="QHostInfo.html#QHostInfo(com.trolltech.qt.network.QHostInfo)"><tt>QHostInfo</tt></a> object.</p> <p>To look up a host's IP addresses asynchronously, call lookupHost(), which takes the host name or IP address, a receiver object, and a slot signature as arguments and returns an ID. You can abort the lookup by calling <a href="QHostInfo.html#abortHostLookup(int)"><tt>abortHostLookup</tt></a> with the lookup ID.</p> <p>Example:</p> <pre><span class="comment"> // To find the IP address of www.trolltech.com</span> QHostInfo::lookupHost(&quot;www.trolltech.com&quot;, this, SLOT(printResults(QHostInfo))); <span class="comment"> // To find the host name for 4.2.2.1</span> QHostInfo::lookupHost(&quot;4.2.2.1&quot;, this, SLOT(printResults(QHostInfo)));</pre> <p>The slot is invoked when the results are ready. (If you use Qtopia Core and disabled multithread support by defining <tt>QT_NO_THREAD</tt>, lookupHost() will block until the lookup has finished.) The results are stored in a <a href="QHostInfo.html#QHostInfo(com.trolltech.qt.network.QHostInfo)"><tt>QHostInfo</tt></a> object. Call <a href="QHostInfo.html#addresses()"><tt>addresses</tt></a> to get the list of IP addresses for the host, and <a href="QHostInfo.html#hostName()"><tt>hostName</tt></a> to get the host name that was looked up.</p> <p>If the lookup failed, <a href="QHostInfo.html#error()"><tt>error</tt></a> returns the type of error that occurred. <a href="QHostInfo.html#errorString()"><tt>errorString</tt></a> gives a human-readable description of the lookup error.</p> <p>If you want a blocking lookup, use the QHostInfo::fromName() function:</p> <pre> QHostInfo info = QHostInfo::fromName(&quot;www.trolltech.com&quot;);</pre> <p><a href="QHostInfo.html#QHostInfo(com.trolltech.qt.network.QHostInfo)"><tt>QHostInfo</tt></a> supports Internationalized Domain Names (IDNs) through the IDNA and Punycode standards.</p> <p>To retrieve the name of the local host, use the static QHostInfo::localHostName() function.</p> @see <a href="QAbstractSocket.html"><tt>QAbstractSocket</tt></a> @see <a href="http://www.rfc-editor.org/rfc/rfc3492.txt">RFC 3492</tt></a> */"> <method name="public QHostInfo(int lookupId)" doc="/** <p>Constructs an empty host info object with lookup ID <tt>lookupId</tt>.</p> @see <a href="QHostInfo.html#lookupId()"><tt>lookupId</tt></a> */"/> <method name="public QHostInfo()" doc="/** <p>Equivalent to <a href="QHostInfo.html#QHostInfo(com.trolltech.qt.network.QHostInfo)"><tt>QHostInfo</tt></a>(-1). */"/> <method name="public QHostInfo(com.trolltech.qt.network.QHostInfo d)" doc="/** <p>Constructs a copy of <tt>d</tt>.</p> */"/> <method name="public final java.util.List<com.trolltech.qt.network.QHostAddress> addresses()" doc="/** <p>Returns the list of IP addresses associated with <a href="QHostInfo.html#hostName()"><tt>hostName</tt></a>. This list may be empty.</p> <p>Example:</p> <pre> QHostInfo info; ... if (!info.addresses().isEmpty()) { QHostAddress address = info.addresses().first(); <span class="comment">// use the first IP address</span> }</pre> @see <a href="QHostInfo.html#setAddresses(java.util.List<com.trolltech.qt.network.QHostAddress>)"><tt>setAddresses</tt></a> @see <a href="QHostInfo.html#hostName()"><tt>hostName</tt></a> @see <a href="QHostInfo.html#error()"><tt>error</tt></a> */"/> <method name="public final com.trolltech.qt.network.QHostInfo.HostInfoError error()" doc="/** <p>Returns the type of error that occurred if the host name lookup failed; otherwise returns <a href="QHostInfo.html#HostInfoError-enum"><tt>NoError</tt></a>.</p> @see <a href="QHostInfo.html#setError(com.trolltech.qt.network.QHostInfo.HostInfoError)"><tt>setError</tt></a> @see <a href="QHostInfo.html#errorString()"><tt>errorString</tt></a> */"/> <method name="public final java.lang.String errorString()" doc="/** <p>If the lookup failed, this function returns a human readable description of the error; otherwise &quot;Unknown error&quot; is returned.</p> @see <a href="QHostInfo.html#setErrorString(java.lang.String)"><tt>setErrorString</tt></a> @see <a href="QHostInfo.html#error()"><tt>error</tt></a> */"/> <method name="public final java.lang.String hostName()" doc="/** <p>Returns the name of the host whose IP addresses were looked up.</p> @see <a href="QHostInfo.html#setHostName(java.lang.String)"><tt>setHostName</tt></a> @see <a href="QHostInfo.html#localHostName()"><tt>localHostName</tt></a> */"/> <method name="public final int lookupId()" doc="/** <p>Returns the ID of this lookup.</p> @see <a href="QHostInfo.html#setLookupId(int)"><tt>setLookupId</tt></a> @see <a href="QHostInfo.html#abortHostLookup(int)"><tt>abortHostLookup</tt></a> @see <a href="QHostInfo.html#hostName()"><tt>hostName</tt></a> */"/> <method name="public final void setAddresses(java.util.List<com.trolltech.qt.network.QHostAddress> addresses)" doc="/** <p>Sets the list of addresses in this <a href="QHostInfo.html#QHostInfo(com.trolltech.qt.network.QHostInfo)"><tt>QHostInfo</tt></a> to <tt>addresses</tt>.</p> @see <a href="QHostInfo.html#addresses()"><tt>addresses</tt></a> */"/> <method name="public final void setError(com.trolltech.qt.network.QHostInfo.HostInfoError error)" doc="/** <p>Sets the error type of this <a href="QHostInfo.html#QHostInfo(com.trolltech.qt.network.QHostInfo)"><tt>QHostInfo</tt></a> to <tt>error</tt>.</p> @see <a href="QHostInfo.html#error()"><tt>error</tt></a> @see <a href="QHostInfo.html#errorString()"><tt>errorString</tt></a> */"/> <method name="public final void setErrorString(java.lang.String errorString)" doc="/** <p>Sets the human readable description of the error that occurred to <tt>errorString</tt> if the lookup failed.</p> @see <a href="QHostInfo.html#errorString()"><tt>errorString</tt></a> @see <a href="QHostInfo.html#setError(com.trolltech.qt.network.QHostInfo.HostInfoError)"><tt>setError</tt></a> */"/> <method name="public final void setHostName(java.lang.String name)" doc="/** <p>Sets the host name of this <a href="QHostInfo.html#QHostInfo(com.trolltech.qt.network.QHostInfo)"><tt>QHostInfo</tt></a> to <tt>name</tt>.</p> @see <a href="QHostInfo.html#hostName()"><tt>hostName</tt></a> */"/> <method name="public final void setLookupId(int id)" doc="/** <p>Sets the ID of this lookup to <tt>id</tt>.</p> @see <a href="QHostInfo.html#lookupId()"><tt>lookupId</tt></a> @see <tt>lookupHost</tt> */"/> <method name="public native static void abortHostLookup(int lookupId)" doc="/** <p>Aborts the host lookup with the ID <tt>lookupId</tt>, as returned by lookupHost().</p> @see <tt>lookupHost</tt> @see <a href="QHostInfo.html#lookupId()"><tt>lookupId</tt></a> */"/> <method name="public native static com.trolltech.qt.network.QHostInfo fromName(java.lang.String name)" doc="/** <p>Looks up the IP address(es) for the given host <tt>name</tt>. The function blocks during the lookup which means that execution of the program is suspended until the results of the lookup are ready. Returns the result of the lookup in a <a href="QHostInfo.html#QHostInfo(com.trolltech.qt.network.QHostInfo)"><tt>QHostInfo</tt></a> object.</p> <p>If you pass a literal IP address to <tt>name</tt> instead of a host name, <a href="QHostInfo.html#QHostInfo(com.trolltech.qt.network.QHostInfo)"><tt>QHostInfo</tt></a> will search for the domain name for the IP (i.e&#x2e;, <a href="QHostInfo.html#QHostInfo(com.trolltech.qt.network.QHostInfo)"><tt>QHostInfo</tt></a> will perform a <i>reverse</i> lookup). On success, the returned <a href="QHostInfo.html#QHostInfo(com.trolltech.qt.network.QHostInfo)"><tt>QHostInfo</tt></a> will contain both the resolved domain name and IP addresses for the host name.</p> @see <tt>lookupHost</tt> */"/> <method name="public native static java.lang.String localHostName()" doc="/** <p>Returns the host name of this machine.</p> @see <a href="QHostInfo.html#hostName()"><tt>hostName</tt></a> */"/> <enum name="HostInfoError" doc="/** <p>This enum describes the various errors that can occur when trying to resolve a host name.</p> @see <a href="QHostInfo.html#error()"><tt>error</tt></a> @see <a href="QHostInfo.html#setError(com.trolltech.qt.network.QHostInfo.HostInfoError)"><tt>setError</tt></a> */"> <enum-value name="NoError" doc="/** <p>The lookup was successful.</p> */"/> <enum-value name="HostNotFound" doc="/** <p>No IP addresses were found for the host.</p> */"/> <enum-value name="UnknownError" doc="/** <p>An unknown error occurred.</p> */"/> </enum> </class>