diff options
Diffstat (limited to 'doc/html/httpd-example.html')
-rw-r--r-- | doc/html/httpd-example.html | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/doc/html/httpd-example.html b/doc/html/httpd-example.html index 1c9bb8c17..aa923a156 100644 --- a/doc/html/httpd-example.html +++ b/doc/html/httpd-example.html @@ -33,7 +33,7 @@ body { background: #ffffff; color: black; } <p> -<p> This example shows how to use the <a href="qserversocket.html">TQServerSocket</a> class. It is a very +<p> This example shows how to use the <a href="ntqserversocket.html">TQServerSocket</a> class. It is a very simple implementation of a HTTP daemon that listens on port 8080 and sends back a simple HTML page back for every GET request it gets. After sending the page, it closes the connection. @@ -49,27 +49,27 @@ sending the page, it closes the connection. ** *****************************************************************************/ #include <stdlib.h> -#include <<a href="qsocket-h.html">qsocket.h</a>> -#include <<a href="qregexp-h.html">qregexp.h</a>> -#include <<a href="qserversocket-h.html">qserversocket.h</a>> -#include <<a href="qapplication-h.html">qapplication.h</a>> -#include <<a href="qmainwindow-h.html">qmainwindow.h</a>> -#include <<a href="qtextstream-h.html">qtextstream.h</a>> -#include <<a href="qvbox-h.html">qvbox.h</a>> -#include <<a href="qlabel-h.html">qlabel.h</a>> -#include <<a href="qtextview-h.html">qtextview.h</a>> -#include <<a href="qpushbutton-h.html">qpushbutton.h</a>> +#include <<a href="qsocket-h.html">ntqsocket.h</a>> +#include <<a href="qregexp-h.html">ntqregexp.h</a>> +#include <<a href="qserversocket-h.html">ntqserversocket.h</a>> +#include <<a href="qapplication-h.html">ntqapplication.h</a>> +#include <<a href="qmainwindow-h.html">ntqmainwindow.h</a>> +#include <<a href="qtextstream-h.html">ntqtextstream.h</a>> +#include <<a href="qvbox-h.html">ntqvbox.h</a>> +#include <<a href="qlabel-h.html">ntqlabel.h</a>> +#include <<a href="qtextview-h.html">ntqtextview.h</a>> +#include <<a href="qpushbutton-h.html">ntqpushbutton.h</a>> // HttpDaemon is the the class that implements the simple HTTP server. -class HttpDaemon : public <a href="qserversocket.html">TQServerSocket</a> +class HttpDaemon : public <a href="ntqserversocket.html">TQServerSocket</a> { <a href="metaobjects.html#Q_OBJECT">Q_OBJECT</a> public: - HttpDaemon( <a href="qobject.html">TQObject</a>* parent=0 ) : - <a href="qserversocket.html">TQServerSocket</a>(8080,1,parent) + HttpDaemon( <a href="ntqobject.html">TQObject</a>* parent=0 ) : + <a href="ntqserversocket.html">TQServerSocket</a>(8080,1,parent) { if ( !ok() ) { - <a href="qapplication.html#qWarning">qWarning</a>("Failed to bind to port 8080"); + <a href="ntqapplication.html#qWarning">qWarning</a>("Failed to bind to port 8080"); exit( 1 ); } } @@ -80,10 +80,10 @@ public: // communication with the client is done over this TQSocket. TQSocket // works asynchronouslyl, this means that all the communication is done // in the two slots readClient() and discardClient(). - <a href="qsocket.html">TQSocket</a>* s = new <a href="qsocket.html">TQSocket</a>( this ); -<a name="x731"></a> connect( s, SIGNAL(<a href="qsocket.html#readyRead">readyRead</a>()), this, SLOT(readClient()) ); -<a name="x729"></a> connect( s, SIGNAL(<a href="qsocket.html#delayedCloseFinished">delayedCloseFinished</a>()), this, SLOT(discardClient()) ); -<a name="x732"></a> s-><a href="qsocket.html#setSocket">setSocket</a>( socket ); + <a href="ntqsocket.html">TQSocket</a>* s = new <a href="ntqsocket.html">TQSocket</a>( this ); +<a name="x731"></a> connect( s, SIGNAL(<a href="ntqsocket.html#readyRead">readyRead</a>()), this, SLOT(readClient()) ); +<a name="x729"></a> connect( s, SIGNAL(<a href="ntqsocket.html#delayedCloseFinished">delayedCloseFinished</a>()), this, SLOT(discardClient()) ); +<a name="x732"></a> s-><a href="ntqsocket.html#setSocket">setSocket</a>( socket ); emit newConnect(); } @@ -98,24 +98,24 @@ private slots: // This slot is called when the client sent data to the server. The // server looks if it was a get request and sends a very simple HTML // document back. - <a href="qsocket.html">TQSocket</a>* socket = (TQSocket*)sender(); -<a name="x727"></a> if ( socket-><a href="qsocket.html#canReadLine">canReadLine</a>() ) { -<a name="x733"></a><a name="x730"></a> <a href="qstringlist.html">TQStringList</a> tokens = TQStringList::<a href="qstringlist.html#split">split</a>( TQRegExp("[ \r\n][ \r\n]*"), socket-><a href="qsocket.html#readLine">readLine</a>() ); + <a href="ntqsocket.html">TQSocket</a>* socket = (TQSocket*)sender(); +<a name="x727"></a> if ( socket-><a href="ntqsocket.html#canReadLine">canReadLine</a>() ) { +<a name="x733"></a><a name="x730"></a> <a href="ntqstringlist.html">TQStringList</a> tokens = TQStringList::<a href="ntqstringlist.html#split">split</a>( TQRegExp("[ \r\n][ \r\n]*"), socket-><a href="ntqsocket.html#readLine">readLine</a>() ); if ( tokens[0] == "GET" ) { - <a href="qtextstream.html">TQTextStream</a> os( socket ); -<a name="x735"></a> os.<a href="qtextstream.html#setEncoding">setEncoding</a>( TQTextStream::UnicodeUTF8 ); + <a href="ntqtextstream.html">TQTextStream</a> os( socket ); +<a name="x735"></a> os.<a href="ntqtextstream.html#setEncoding">setEncoding</a>( TQTextStream::UnicodeUTF8 ); os << "HTTP/1.0 200 Ok\r\n" "Content-Type: text/html; charset=\"utf-8\"\r\n" "\r\n" "<h1>Nothing to see here</h1>\n"; -<a name="x728"></a> socket-><a href="qsocket.html#close">close</a>(); +<a name="x728"></a> socket-><a href="ntqsocket.html#close">close</a>(); emit wroteToClient(); } } } void discardClient() { - <a href="qsocket.html">TQSocket</a>* socket = (TQSocket*)sender(); + <a href="ntqsocket.html">TQSocket</a>* socket = (TQSocket*)sender(); delete socket; emit endConnect(); } @@ -124,7 +124,7 @@ private slots: // HttpInfo provides a simple graphical user interface to the server and shows // the actions of the server. -class HttpInfo : public <a href="qvbox.html">TQVBox</a> +class HttpInfo : public <a href="ntqvbox.html">TQVBox</a> { Q_OBJECT public: @@ -132,20 +132,20 @@ public: { HttpDaemon *httpd = new HttpDaemon( this ); - <a href="qstring.html">TQString</a> itext = TQString( + <a href="ntqstring.html">TQString</a> itext = TQString( "This is a small httpd example.\n" "You can connect with your\n" "web browser to port %1" -<a name="x726"></a> ).arg( httpd-><a href="qserversocket.html#port">port</a>() ); - <a href="qlabel.html">TQLabel</a> *lb = new <a href="qlabel.html">TQLabel</a>( itext, this ); - lb-><a href="qlabel.html#setAlignment">setAlignment</a>( AlignHCenter ); - infoText = new <a href="qtextview.html">TQTextView</a>( this ); - <a href="qpushbutton.html">TQPushButton</a> *quit = new <a href="qpushbutton.html">TQPushButton</a>( "quit" , this ); +<a name="x726"></a> ).arg( httpd-><a href="ntqserversocket.html#port">port</a>() ); + <a href="ntqlabel.html">TQLabel</a> *lb = new <a href="ntqlabel.html">TQLabel</a>( itext, this ); + lb-><a href="ntqlabel.html#setAlignment">setAlignment</a>( AlignHCenter ); + infoText = new <a href="ntqtextview.html">TQTextView</a>( this ); + <a href="ntqpushbutton.html">TQPushButton</a> *quit = new <a href="ntqpushbutton.html">TQPushButton</a>( "quit" , this ); connect( httpd, SIGNAL(newConnect()), SLOT(newConnect()) ); connect( httpd, SIGNAL(endConnect()), SLOT(endConnect()) ); connect( httpd, SIGNAL(wroteToClient()), SLOT(wroteToClient()) ); -<a name="x724"></a> connect( quit, SIGNAL(<a href="qbutton.html#pressed">pressed</a>()), qApp, SLOT(<a href="qapplication.html#quit">quit</a>()) ); +<a name="x724"></a> connect( quit, SIGNAL(<a href="ntqbutton.html#pressed">pressed</a>()), qApp, SLOT(<a href="ntqapplication.html#quit">quit</a>()) ); } ~HttpInfo() @@ -155,29 +155,29 @@ public: private slots: void newConnect() { -<a name="x734"></a> infoText-><a href="qtextedit.html#append">append</a>( "New connection" ); +<a name="x734"></a> infoText-><a href="ntqtextedit.html#append">append</a>( "New connection" ); } void endConnect() { - infoText-><a href="qtextedit.html#append">append</a>( "Connection closed\n\n" ); + infoText-><a href="ntqtextedit.html#append">append</a>( "Connection closed\n\n" ); } void wroteToClient() { - infoText-><a href="qtextedit.html#append">append</a>( "Wrote to client" ); + infoText-><a href="ntqtextedit.html#append">append</a>( "Wrote to client" ); } private: - <a href="qtextview.html">TQTextView</a> *infoText; + <a href="ntqtextview.html">TQTextView</a> *infoText; }; int main( int argc, char** argv ) { - <a href="qapplication.html">TQApplication</a> app( argc, argv ); + <a href="ntqapplication.html">TQApplication</a> app( argc, argv ); HttpInfo info; - app.<a href="qapplication.html#setMainWidget">setMainWidget</a>( &info ); - info.<a href="qwidget.html#show">show</a>(); - return app.<a href="qapplication.html#exec">exec</a>(); + app.<a href="ntqapplication.html#setMainWidget">setMainWidget</a>( &info ); + info.<a href="ntqwidget.html#show">show</a>(); + return app.<a href="ntqapplication.html#exec">exec</a>(); } #include "httpd.moc" |