Sophie

Sophie

distrib > Mandriva > 8.2 > i586 > media > contrib > by-pkgid > 112b0974ad288f6cd55bf971ee6026a9 > files > 796

libqt3-devel-3.0.2-2mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /tmp/qt-3.0-reggie-28534/qt-x11-free-3.0.2/doc/network.doc:36 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Network Module</title>
<style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
 <a href="index.html">
<font color="#004faf">Home</font></a>
 | <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
 | <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
 | <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
 | <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
 | <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>Network Module</h1>



<p> This module is part of the <a href="editions.html">Qt Enterprise Edition</a>.
<p> <!-- toc -->
<ul>
<li><a href="#1"> Introduction
</a>
<li><a href="#2"> Working Network Protocol independent with QUrlOperator and QNetworkOperation
</a>
<ul>
<li><a href="#2-1"> Implementing your own Network Protocol
</a>
<li><a href="#2-2"> Error Handling
</a>
</ul>
</ul>
<!-- endtoc -->

<p> <h2> Introduction
</h2>
<a name="1"></a><p> The network module offers classes to make network programming easier
and portable. Basically there are three sets of classes, first very
basic classes like <a href="qsocket.html">QSocket</a>, <a href="qserversocket.html">QServerSocket</a>, <a href="qdns.html">QDns</a>, etc. which
allow to work in a portable way with TCP/IP sockets. In addition,
there are classes like <a href="qnetworkprotocol.html">QNetworkProtocol</a>, <a href="qnetworkoperation.html">QNetworkOperation</a> in
the Qt base library, which provide an abstract layer for implementing
network protocols and <a href="qurloperator.html">QUrlOperator</a> which operates on such network
protocols. Finally the third set of network classes are the passive
ones, namely <a href="qurl.html">QUrl</a> and <a href="qurlinfo.html">QUrlInfo</a> which do URL parsing and similar
stuff.
<p> The first set of classes (<a href="qsocket.html">QSocket</a>, <a href="qserversocket.html">QServerSocket</a>, <a href="qdns.html">QDns</a>, <a href="qftp.html">QFtp</a>, etc.)
are included in the "network" module of Qt.
<p> The <a href="qsocket.html">QSocket</a> classes are not directly related to the QNetwork classes,
but QSocket should and will be used for implementing network
protocols, which are directly related to the QNetwork
classes. E.g. the <a href="qftp.html">QFtp</a> class (implementation of the FTP protocol) uses
QSockets. But QSockets don't need to be used for protocol
implementations, e.g. <a href="qlocalfs.html">QLocalFs</a> (which is an implementation of the
local filesystem as network protocol) uses <a href="qdir.html">QDir</a> and no QSocket. Using
QNetworkProtocols you can implement everything which fits into a
hierarchical structure and can be accessed using URLs. This could be
e.g. a protocol which can read pictures from a digital camera using a
serial connection.
<p> <h2> Working Network Protocol independent with <a href="qurloperator.html">QUrlOperator</a> and <a href="qnetworkoperation.html">QNetworkOperation</a>
</h2>
<a name="2"></a><p> To just use existing network protocol implementations and operate on
URLs using them is quite easy. E.g. downloading a file from an FTP
server to the local filesystem can be done with following code:
<p> <pre>
    <a href="qurloperator.html">QUrlOperator</a> op;
    op.<a href="qurloperator.html#copy">copy</a>( "ftp://ftp.trolltech.com/qt/source/qt-2.1.0.tar.gz", "file:/tmp", FALSE );
</pre>
 
<p> And that's all! Of course an implementation of the FTP protocol has to be available
and registered for doing that. More information on that later.
<p> You can also do stuff like creating directories, removing files, renaming, etc. E.g. to
create a folder on a private FTP account do
<p> <pre>
    <a href="qurloperator.html">QUrlOperator</a> op( "ftp://username:password@host.domain.no/home/username" );
    op.<a href="qurloperator.html#mkdir">mkdir</a>( "New Directory" );
</pre>
 
<p> That's it again. To see all available operations, look at the <a href="qurloperator.html">QUrlOperator</a> class
documentation.
<p> Now as everything works asynchronous, the function call for an operation returns
before the operation has been processed. So you don't get a return value which
tells you something about failure or success. The return value always is a pointer
to a <a href="qnetworkoperation.html">QNetworkOperation</a>.
<p> In this <a href="qnetworkoperation.html">QNetworkOperation</a> all information about the operation is stored.
There is e.g. a method of <a href="qnetworkoperation.html">QNetworkOperation</a> which returns the state of
this operation. Using that you can find out all the time in which state the operation
currently is. Also you get the arguments you passed to the <a href="qurloperator.html">QUrlOperator</a>
method, the type of the operation and some more stuff from this <a href="qnetworkoperation.html">QNetworkOperation</a>
object. For more details see the class documentation of <a href="qnetworkoperation.html">QNetworkOperation</a>.
<p> Now, later you get signals emitted by the <a href="qurloperator.html">QUrlOperator</a>, which inform you about the process
of the operations. As you can call many methods which operate on a URL of one
<a href="qurloperator.html">QUrlOperator</a>, it queues up all these operations. So you can't know which operation
the <a href="qurloperator.html">QUrlOperator</a> just processes. Because of this you get in each signal as the last argument
a pointer to the <a href="qnetworkoperation.html">QNetworkOperation</a> object which is just processed and from which this
signal comes.
<p> Some of these operations send a <tt>start()</tt> signal at the beginning (depending if it makes
sense or not), then some of them send some signals during processing the operation,
and <em>all</em> operations send a <tt>finished()</tt> signal after they are done. Now, finished
could mean that the operation has been successfully finished or that it failed. To find
that out you can use the <a href="qnetworkoperation.html">QNetworkOperation</a> pointer you got with the <tt>finished()</tt>
signal. If <a href="qnetworkoperation.html#state">QNetworkOperation::state</a>() equals <a href="qnetworkprotocol.html#State-enum">QNetworkProtocol::StDone</a> the
operation finished successful, if it is <a href="qnetworkprotocol.html#State-enum">QNetworkProtocol::StFailed</a> the operation failed.
<p> Now, a slot which you connected to the <tt>QUrlOperator::finished( QNetworkOperation * )</tt>
signal could look like this
<p> <pre>

void MyClass::slotOperationFinished( <a href="qnetworkoperation.html">QNetworkOperation</a> *op )
{
    switch ( op-&gt;<a href="qnetworkoperation.html#operation">operation</a>() ) {
    case QNetworkProtocol::OpMkDir: {
        if ( op-&gt;<a href="qnetworkoperation.html#state">state</a>() == QNetworkProtocol::StFailed )
            <a href="qapplication.html#qDebug">qDebug</a>( "Couldn't create directory %s", op-&gt;<a href="qnetworkoperation.html#arg">arg</a>( 0 ).latin1() );
        else
            <a href="qapplication.html#qDebug">qDebug</a>( "Successfully created directory %s", op-&gt;<a href="qnetworkoperation.html#arg">arg</a>( 0 ).latin1() );
    } break;
    // ... and so on
    }
}

</pre>
 
<p> As mentioned before, some operations send other signals too. Let's take
the list children operation as an example (e.g. read the directory of a
directory on a FTP server):
<p> <pre>

QUrlOperator op;

MyClass::MyClass() : <a href="qobject.html">QObject</a>(), op( "ftp://ftp.trolltech.com" )
{
    connect( &amp;op, SIGNAL( newChildren( const <a href="qvaluelist.html">QValueList</a>&lt;QUrlInfo&gt; &amp;, QNetworkOperation * ) ),
             this, SLOT( slotInsertEntries( const <a href="qvaluelist.html">QValueList</a>&lt;QUrlInfo&gt; &amp;, QNetworkOperation * ) ) );
    connect( &amp;op, SIGNAL( start( <a href="qnetworkoperation.html">QNetworkOperation</a> * ) ),
             this, SLOT( slotStart( <a href="qnetworkoperation.html">QNetworkOperation</a> *) ) );
    connect( &amp;op, SIGNAL( finished( <a href="qnetworkoperation.html">QNetworkOperation</a> * ) ),
             this, SLOT( slotFinished( <a href="qnetworkoperation.html">QNetworkOperation</a> *) ) );
}

void MyClass::slotInsertEntries( const <a href="qvaluelist.html">QValueList</a>&lt;QUrlInfo&gt; &amp;info, QNetworkOperation * )
{
    QValueList&lt;QUrlInfo&gt;::ConstIterator it = info.<a href="qvaluelist.html#begin">begin</a>();
    for ( ; it != info.<a href="qvaluelist.html#end">end</a>(); ++it ) {
        const <a href="qurlinfo.html">QUrlInfo</a> &amp;inf = *it;
        <a href="qapplication.html#qDebug">qDebug</a>( "Name: %s, Size: %d, Last Modified: %s",
            inf.<a href="qurlinfo.html#name">name</a>().latin1(), inf.<a href="qurlinfo.html#size">size</a>(), inf.<a href="qurlinfo.html#lastModified">lastModified</a>().toString().latin1() );
    }
}

void MyClass::slotStart( <a href="qnetworkoperation.html">QNetworkOperation</a> * )
{
    <a href="qapplication.html#qDebug">qDebug</a>( "Start reading '%s'", op.toString().latin1() );
}

void MyClass::slotFinished( <a href="qnetworkoperation.html">QNetworkOperation</a> *operation )
{
    if ( operation-&gt;<a href="qnetworkoperation.html#operation">operation</a>() == QNetworkProtocol::OpListChildren ) {
        if ( operation-&gt;<a href="qnetworkoperation.html#state">state</a>() == QNetworkProtocol::StFailed )
            <a href="qapplication.html#qDebug">qDebug</a>( "Couldn't read '%s'! Following error occurred: %s",
                op.toString().latin1(), operation-&gt;<a href="qnetworkoperation.html#protocolDetail">protocolDetail</a>().latin1() );
        else
            <a href="qapplication.html#qDebug">qDebug</a>( "Finished reading '%s'!", op.toString().latin1() );
    }
}

</pre>
 
<p> These examples explained now how to use the <a href="qurloperator.html">QUrlOperator</a> and <tt>QNetworkOperations</tt>.
The network extension will contain some good examples for this too.
<p> <h3> Implementing your own Network Protocol
</h3>
<a name="2-1"></a><p> <a href="qnetworkprotocol.html">QNetworkProtocol</a> provides a base class for implementations
of network protocols and an architecture to a dynamic registration
and unregistration of network protocols. If you use this architecture
you also don't need to care about asynchronous programming, as the
architecture hides this and does all the work for you.
<p> Limitation: As it is quite hard to design a base class for
network protocols which satisfies all network protocols,
the architecture described here is designed to work with all kinds
of hierarchical structures, like filesystems. So everything which can
be interpreted as hierarchical structure and accessed via URLs,
can be implemented as network protocol and easily used in Qt. This
is not limited to filesystems only!
<p> To implement a network protocol create a class derived from
<a href="qnetworkprotocol.html">QNetworkProtocol</a>.
<p> Other classes will use this network protocol implementation
to operate on it. So you should reimplement following protected members
<p> <pre>
    void QNetworkProtocol::operationListChildren( <a href="qnetworkoperation.html">QNetworkOperation</a> *op );
    void QNetworkProtocol::operationMkDir( <a href="qnetworkoperation.html">QNetworkOperation</a> *op );
    void QNetworkProtocol::operationRemove( <a href="qnetworkoperation.html">QNetworkOperation</a> *op );
    void QNetworkProtocol::operationRename( <a href="qnetworkoperation.html">QNetworkOperation</a> *op );
    void QNetworkProtocol::operationGet( <a href="qnetworkoperation.html">QNetworkOperation</a> *op );
    void QNetworkProtocol::operationPut( <a href="qnetworkoperation.html">QNetworkOperation</a> *op );
</pre>
 
<p> Some words about how to reimplement these methods: You always get a pointer to
a <a href="qnetworkoperation.html">QNetworkOperation</a> as argument.  This pointer holds all information about
the operation in the current state.  If you start processing such an operation,
set the state to <a href="qnetworkprotocol.html#State-enum">QNetworkProtocol::StInProgress</a>.  If you finished processing
the operation, set the state to <a href="qnetworkprotocol.html#State-enum">QNetworkProtocol::StDone</a> if it was
successful or <a href="qnetworkprotocol.html#State-enum">QNetworkProtocol::StFailed</a> if an error occurred. If an
error occurred you have to set an error code (see <a href="qnetworkoperation.html#setErrorCode">QNetworkOperation::setErrorCode</a>() )
and if you know some details (e.g. an error message) you can also set this
message to the operation pointer (see <a href="qnetworkoperation.html#setProtocolDetail">QNetworkOperation::setProtocolDetail</a>() ).
Also you get all information (type, arguments, etc.) of the operation
from this <a href="qnetworkoperation.html">QNetworkOperation</a> pointer. For details about which arguments
you can get and set look at the class documentation of <a href="qnetworkoperation.html">QNetworkOperation</a>.
<p> If you reimplement such an operation method, it's also very important
to emit the correct signals at the correct time: In general always emit
at the end of an operation (when you either successfully finished processing
the operation or and error occurred) the <tt>finished()</tt> signal with
the network operation as argument. The whole network architecture
relies on correctly emitted <tt>finished()</tt> signals! So be careful with that!
Then there are some more special signals which are specific to operations:
<ul>
<li> Emit in <tt>operationListChildren</tt>:
<ul>
<li>  <tt>start()</tt> just before starting listing the children
<li>  <tt>newChildren()</tt> when new children are read
</ul>
<li> Emit in <tt>operationMkDir</tt>:
<ul>
<li>  <tt>createdDirectory()</tt> after the directory has been created
<li>  <tt>newChild()</tt> (or newChildren()) after the directory has been
created (as a new directory is a new child)
</ul>
<li> Emit in <tt>operationRemove</tt>:
<ul>
<li>  <tt>removed()</tt> after the child has been removed
</ul>
<li> Emit in <tt>operationRename</tt>:
<ul>
<li>  <tt>itemChanged()</tt> after the child has been renamed
</ul>
<li> Emit in <tt>operationGet</tt>:
<ul>
<li>  <tt>data()</tt> each time new data has been read
<li>  <tt>dataTransferProgress()</tt> each time new data has been read to
indicate how much of the data has been read now.
</ul>
<li> Emit in <tt>operationPut</tt>:
<ul>
<li>  <tt>dataTransferProgress()</tt> each time data has been written to
indicate how much of the data has been written. Although you
know the whole data when this operation is called, it's
suggested not to write the whole data at once, but to do it
step by step to avoid blocking the GUI and also this way the
progress can be made visible to the user.
</ul>
</ul>
<p> And remember, always emit the <tt>finished()</tt> signal at the end!
<p> For more details about the arguments of these signals take a look
at the <a href="qnetworkprotocol.html">QNetworkProtocol</a> class documentation.
<p> Now, as argument in such a method you get the <a href="qnetworkoperation.html">QNetworkOperation</a>
which you process. Here is a list which arguments of the <a href="qnetworkoperation.html">QNetworkOperation</a>
you can get and which you have to set in which method:
<p> (To get the URL on which you should work, use the <a href="qnetworkprotocol.html#url">QNetworkProtocol::url</a>() method
which returns the pointer to the URL operator. Using that you can get the path, host,
name filter and everything else of the URL)
<p> <ul>
<li> In <tt>operationListChildren</tt>:
<ul>
<li>   Nothing.
</ul>
<li> In <tt>operationMkDir</tt>:
<ul>
<li>  <tt>QNetworkOperation::arg( 0 )</tt> contains the name of the directory which should be created
</ul>
<li> In <tt>operationRemove</tt>:
<ul>
<li>  <tt>QNetworkOperation::arg( 0 )</tt> contains the name of the file
which should be removed. Normally this is a relative name. But
it may be absolute too, so use <a href="qurl.html">QUrl</a>( op->arg( 0 ) ).fileName()
to get the filename.
</ul>
<li> In <tt>operationRename</tt>:
<ul>
<li>  <tt>QNetworkOperation::arg( 0 )</tt> contains the name of the file
which should be renamed
<li>  <tt>QNetworkOperation::arg( 1 )</tt> contains the name to which it
should be renamed.
</ul>
<li> In <tt>operationGet</tt>:
<ul>
<li>  <tt>QNetworkOperation::arg( 0 )</tt> contains the full URL of the
file which should be retrieved.
</ul>
<li> In <tt>operationPut</tt>:
<ul>
<li>  <tt>QNetworkOperation::arg( 0 )</tt> contains the full URL of the
file in which the data should be stored.
<li>  <tt>QNetworkOperation::rawArg( 1 )</tt> contains the data which
should be stored in <tt>QNetworkOperation::arg( 0 )</tt>
</ul>
</ul>
<p> So, to sum it up: If you reimplement such an operation method, you
have to emit some special signals and <em>always</em> at the end a
<tt>finished()</tt> signal, either on success or on failure. Also you have to change
the state of the <a href="qnetworkoperation.html">QNetworkOperation</a> during processing it and can get
and set arguments of the operation as well.
<p> But it's unlikely that the network protocol you implement supports
all these operations. So, just reimplement the operations, which
are supported by the protocol. Additionally you have to specify which
operations are supported then. This is done by reimplementing
<p> <pre>
    int QNetworkProtocol::supportedOperations() const;
</pre>
 
<p> In your implementation of this method return an int value
which is constructed by or'ing together the correct values
(supported operations) of the following enum (of <a href="qnetworkprotocol.html">QNetworkProtocol</a>):
<p> <pre>
    enum Operation {
        OpListChildren = 1,
        OpMkDir = 2,
        OpRemove = 4,
        OpRename = 8,
        OpGet = 32,
        OpPut = 64
    };
</pre>
 
<p> So, if your protocol e.g. supports listing children and renaming them, do
in your implementation of <tt>supportedOperations()</tt>:
<p> <pre>
    return OpListChildren | OpRename;
</pre>
 
<p> The last method you have to reimplement is
<p> <pre>
    bool QNetworkProtocol::checkConnection( <a href="qnetworkoperation.html">QNetworkOperation</a> *op );
</pre>
 
<p> Here you have to return TRUE, if the connection is up and ok (this means
operations on the protocol can be done). If the connection is not ok,
return FALSE and start to try opening it. If you will not be able to open the
connection at all (e.g. because the host is not found), emit a <tt>finished()</tt>
signal and set an error code and the <a href="qnetworkprotocol.html#State-enum">QNetworkProtocol::StFailed</a> state to
the <a href="qnetworkoperation.html">QNetworkOperation</a> pointer you get here.
<p> Now, you never need to check before doing an operation yourself,
if the connection is ok. The network architecture does this, this means
using <tt>checkConnection()</tt> it looks if an operation could be done and if
not, it tries it again and again for some time and only calls an operation
method if the connection is ok.
<p> Using this knowledge it should be possible to implement network protocols. Finally
to be able to use it with a <a href="qurloperator.html">QUrlOperator</a> (and so e.g. in the <a href="qfiledialog.html">QFileDialog</a>), you have to
register the network protocol implementation. This can be done like this:
<p> <pre>
    QNetworkProtocol::<a href="qnetworkprotocol.html#registerNetworkProtocol">registerNetworkProtocol</a>( "myprot", new QNetworkProtocolFactory&lt;MyProtocol&gt; );
</pre>
 
<p> In this case <tt>MyProtocol</tt> would be a class you implemented like described here
(derived from <a href="qnetworkprotocol.html">QNetworkProtocol</a>) and the name of the protocol would be
myprot. So if you want to use it, you would do something like
<p> <pre>
    <a href="qurloperator.html">QUrlOperator</a> op( "myprot://host/path" );
    op.<a href="qurloperator.html#listChildren">listChildren</a>();
</pre>
 
<p> Finally as example for a network protocol implementation you could look at the
implementation of <a href="qlocalfs.html">QLocalFs</a>. The network extension will also contain an example
implementation of a network protocol
<p> <h3> Error Handling
</h3>
<a name="2-2"></a><p> Error handling is important for both, implementing new network protocols and using
them (through <a href="qurloperator.html">QUrlOperator</a>). So first some words about error handling when using
the network protocols:
<p> As already mentioned quite some times after processing an operation has been finished
the network operation and so the <a href="qurloperator.html">QUrlOperator</a> emits the <tt>finished()</tt> signal. This has
as argument the pointer to the processed <a href="qnetworkoperation.html">QNetworkOperation</a>. If the state of this operation
is <a href="qnetworkprotocol.html#State-enum">QNetworkProtocol::StFailed</a>, the operation contains some more information about this
error. Following error codes are defined in <a href="qnetworkprotocol.html">QNetworkProtocol</a>:
<p> <ul>
<li> <a href="qnetworkprotocol.html#Error-enum">QNetworkProtocol::NoError</a> - No error occurred
<li> <a href="qnetworkprotocol.html#Error-enum">QNetworkProtocol::ErrValid</a> - The URL you are operating on is not valid
<li> <a href="qnetworkprotocol.html#Error-enum">QNetworkProtocol::ErrUnknownProtocol</a> - There is no protocol implementation available for the protocol of the URL you are operating on (e.g. if the protocol is http and no http implementation has been registered)
<li> <a href="qnetworkprotocol.html#Error-enum">QNetworkProtocol::ErrUnsupported</a> - The operation is not supported by the protocol
<li> <a href="qnetworkprotocol.html#Error-enum">QNetworkProtocol::ErrParse</a> - Parse error of the URL
<li> <a href="qnetworkprotocol.html#Error-enum">QNetworkProtocol::ErrLoginIncorrect</a> - You needed to login but the username and or password are wrong
<li> <a href="qnetworkprotocol.html#Error-enum">QNetworkProtocol::ErrHostNotFound</a> - The specified host (in the URL) couldn't be found
<li> <a href="qnetworkprotocol.html#Error-enum">QNetworkProtocol::ErrListChildren</a> - An error occurred while listing the children
<li> <a href="qnetworkprotocol.html#Error-enum">QNetworkProtocol::ErrMkDir</a> - An error occurred when creating a directory
<li> <a href="qnetworkprotocol.html#Error-enum">QNetworkProtocol::ErrRemove</a> -An error occurred while removing a child
<li> <a href="qnetworkprotocol.html#Error-enum">QNetworkProtocol::ErrRename</a> - An error occurred while renaming a child
<li> <a href="qnetworkprotocol.html#Error-enum">QNetworkProtocol::ErrGet</a> - An error occurred while getting (retrieving) data
<li> <a href="qnetworkprotocol.html#Error-enum">QNetworkProtocol::ErrPut</a> - An error occurred while putting (uploading) data
<li> <a href="qnetworkprotocol.html#Error-enum">QNetworkProtocol::ErrFileNotExisting</a> - A file which is needed by the operation doesn't exist
<li> <a href="qnetworkprotocol.html#Error-enum">QNetworkProtocol::ErrPermissionDenied</a> - The permission for doing the operation has been denied
</ul>
<p> <a href="qnetworkoperation.html#errorCode">QNetworkOperation::errorCode</a>() returns then one of these codes or maybe a different one
if you use an own network protocol implementation which defines additional error codes.
<p> <tt>QNetworkOperation::protocolDetails()</tt> may also return a string which contains an error
message then which could e.g. be displayed for the user.
<p> According to this information it should be possible to react on errors.
<p> Now, if you implement your own network protocol, you will need to tell about errors
which occurred. First you always need to be able to access the <a href="qnetworkoperation.html">QNetworkOperation</a>
which is processed at the moment. This can be done using <tt>QNetworkOperation::operationInProgress()</tt>,
which returns a pointer to the current network operation or 0 if no operation is processed at the moment.
<p> Now if and error occurred and you need to handle it, do
<p> <pre>

    if ( operationInProgress() ) {
        operationInProgress()-&gt;setErrorCode( error_code_of_your_error );
        operationInProgress()-&gt;setProtocolDetails( detail ); // optional!
        emit finished( operationInProgress() );
        return;
    }

</pre>
 
<p> That's all. The connection to the <a href="qurloperator.html">QUrlOperator</a> and so on is done automatically. Additionally,
if the error was really bad so that no more operations can be done in the current state (e.g.
if the host couldn't be found), call
<tt>QNetworkProtocol::clearOperationStack()</tt> <em>before</em> emitting <tt>finished()</tt>.
<p> Now, as error code you should use, if possible, one of the predefined error codes
of <a href="qnetworkprotocol.html">QNetworkProtocol</a>. If this is not possible, you can add own error codes - they are
just normal <tt>integers</tt>. Just be careful that the value of the error code doesn't conflict
with an existing one.
<p> Documentation about the low-level classes like <a href="qsocket.html">QSocket</a>, <a href="qdns.html">QDns</a>, etc. will be included
in the seperate network extension.
<p> For internal use only.
<!-- eof -->
<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2001 
<a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt version 3.0.2</div>
</table></div></address></body>
</html>