diff --git a/qtservice/examples/server/main.cpp b/qtservice/examples/server/main.cpp
index ebcc218..16ca028 100644
--- a/qtservice/examples/server/main.cpp
+++ b/qtservice/examples/server/main.cpp
@@ -44,139 +44,97 @@
 #include <QTextStream>
 #include <QDateTime>
 #include <QStringList>
+#include <QLibraryInfo>
 #include <QDir>
 #include <QSettings>
+#include <stdlib.h>
+#include <qt_windows.h>
 
 #include "qtservice.h"
 
-// HttpDaemon is the the class that implements the simple HTTP server.
-class HttpDaemon : public QTcpServer
+void formatByteArray(const QByteArray &b, QTextStream &s)
 {
-    Q_OBJECT
-public:
-    HttpDaemon(quint16 port, QObject* parent = 0)
-        : QTcpServer(parent), disabled(false)
-    {
-        listen(QHostAddress::Any, port);
-    }
-
-    void incomingConnection(int socket)
-    {
-        if (disabled)
-            return;
-
-        // When a new client connects, the server constructs a QTcpSocket and all
-        // communication with the client is done over this QTcpSocket. QTcpSocket
-        // works asynchronously, this means that all the communication is done
-        // in the two slots readClient() and discardClient().
-        QTcpSocket* s = new QTcpSocket(this);
-        connect(s, SIGNAL(readyRead()), this, SLOT(readClient()));
-        connect(s, SIGNAL(disconnected()), this, SLOT(discardClient()));
-        s->setSocketDescriptor(socket);
-
-        QtServiceBase::instance()->logMessage("New Connection");
-    }
-
-    void pause()
-    {
-        disabled = true;
-    }
-
-    void resume()
-    {
-        disabled = false;
-    }
-
-private slots:
-    void readClient()
-    {
-        if (disabled)
-            return;
-
-        // 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.
-        QTcpSocket* socket = (QTcpSocket*)sender();
-        if (socket->canReadLine()) {
-            QStringList tokens = QString(socket->readLine()).split(QRegExp("[ \r\n][ \r\n]*"));
-            if (tokens[0] == "GET") {
-                QTextStream os(socket);
-                os.setAutoDetectUnicode(true);
-                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"
-                    << QDateTime::currentDateTime().toString() << "\n";
-                socket->close();
-
-                QtServiceBase::instance()->logMessage("Wrote to client");
-
-                if (socket->state() == QTcpSocket::UnconnectedState) {
-                    delete socket;
-                    QtServiceBase::instance()->logMessage("Connection closed");
-                }
-            }
+    for (int i = 0; i < b.size(); ++i) {
+        char c = b.at(i);
+        const unsigned uc = (unsigned char)(c);
+        if (uc < 128) {
+            s << c;
+        } else {
+            s << "(\\0x" << hex << uc << dec << ')';
         }
     }
-    void discardClient()
-    {
-        QTcpSocket* socket = (QTcpSocket*)sender();
-        socket->deleteLater();
+}
 
-        QtServiceBase::instance()->logMessage("Connection closed");
+void formatArgv(const char *prefix, int argc, char **argv, QTextStream &s)
+{
+    s << prefix << '=' << showbase << hex << quintptr(argv) << dec << noshowbase
+      << ", argc=" << argc << '\n';
+    for (int i = 0; i < argc; ++i) {
+        s << prefix  << '[' << i << "]=" << showbase << hex << quintptr(argv[i]) << dec << noshowbase
+          << "=\"";
+        formatByteArray(argv[i], s);
+        s << "\"\n";
     }
+    s << '\n';
+}
 
-private:
-    bool disabled;
-};
+void formatArgList(const char *prefix, const QStringList &l, QTextStream &s)
+{
+    for (int i = 0; i < l.size(); ++i)
+        s << prefix  << '[' << i << "]=\"" << l.at(i) << "\"\n";
+}
 
 class HttpService : public QtService<QCoreApplication>
 {
 public:
     HttpService(int argc, char **argv)
-	: QtService<QCoreApplication>(argc, argv, "Qt HTTP Daemon")
+    : QtService<QCoreApplication>(argc, argv, "Qt HTTP Daemon" QT_VERSION_STR)
     {
-        setServiceDescription("A dummy HTTP service implemented with Qt");
+        QString t = "A dummy test service implemented with Qt. ";
+#if QT_VERSION >= 0x050000
+        t += QLibraryInfo::build();
+#else
+        t += QT_VERSION_STR;
+#endif
+        setServiceDescription(t);
         setServiceFlags(QtServiceBase::CanBeSuspended);
     }
 
 protected:
     void start()
     {
-        QCoreApplication *app = application();
-
-#if QT_VERSION < 0x040100
-        quint16 port = (app->argc() > 1) ?
-                QString::fromLocal8Bit(app->argv()[1]).toUShort() : 8080;
-#else
-        const QStringList arguments = QCoreApplication::arguments();
-        quint16 port = (arguments.size() > 1) ?
-                arguments.at(1).toUShort() : 8080;
-#endif
-        daemon = new HttpDaemon(port, app);
-
-        if (!daemon->isListening()) {
-            logMessage(QString("Failed to bind to port %1").arg(daemon->serverPort()), QtServiceBase::Error);
-            app->quit();
-        }
+        logMessage(serviceDescription());
     }
 
-    void pause()
+    void processCommand(int code)
     {
-	daemon->pause();
-    }
+        switch (code) {
+        case 1: {
+            QString s;
+            QTextStream str(&s);
+            str << __FUNCTION__ << code << '\n'
+                << "\nGetCommandLineW: \"" << QString::fromWCharArray(GetCommandLineW()) << "\"\n";
+            formatArgv("__argv", __argc, __argv, str);
+#if QT_VERSION < 0x050000
+            formatArgv("QCoreApplication::argv()", QCoreApplication::argc(), QCoreApplication::argv(), str);
+#endif
+            logMessage(s);
+        }
+            break;
+        case 2:{
+            QString s;
+            QTextStream str(&s);
+            str << __FUNCTION__ << code << '\n';
+            formatArgList("QCoreApplication", QCoreApplication::arguments(), str);
+            logMessage(s);
+        }
+            break;
+        }
 
-    void resume()
-    {
-	daemon->resume();
     }
 
-private:
-    HttpDaemon *daemon;
 };
 
-#include "main.moc"
-
 int main(int argc, char **argv)
 {
 #if !defined(Q_OS_WIN)
diff --git a/qtservice/examples/server/server.pro b/qtservice/examples/server/server.pro
index 608b4d5..5af81a1 100644
--- a/qtservice/examples/server/server.pro
+++ b/qtservice/examples/server/server.pro
@@ -1,8 +1,14 @@
-TARGET   = httpservice
+
 TEMPLATE = app
 CONFIG   += console qt
 QT = core network 
 
+DEFINES+=QTSERVICE_DEBUG
 SOURCES  = main.cpp
+greaterThan(QT_MAJOR_VERSION, 4) {
+   TARGET   = httpservice5
+} else {
+   TARGET   = httpservice4
+}
 
 include(../../src/qtservice.pri)
diff --git a/qtservice/src/qtservice.cpp b/qtservice/src/qtservice.cpp
index 837254b..01e1544 100644
--- a/qtservice/src/qtservice.cpp
+++ b/qtservice/src/qtservice.cpp
@@ -93,7 +93,10 @@ void qtServiceLogDebug(QtMsgType type, const char* msg)
 
     if (!f) {
 #if defined(Q_OS_WIN32)
-        f = new QFile("c:/service-debuglog.txt");
+        QString fn = "c:/service-debuglog";
+        fn += QString::fromLatin1(QT_VERSION_STR).remove('.');
+        fn += ".txt";
+        f = new QFile(fn);
 #else
         f = new QFile("/tmp/service-debuglog.txt");
 #endif
@@ -106,6 +109,7 @@ void qtServiceLogDebug(QtMsgType type, const char* msg)
         f->write(ps);
     }
 
+
     switch (type) {
     case QtWarningMsg:
         s += "WARNING: ";
@@ -858,6 +862,7 @@ int QtServiceBase::exec()
     }
 #endif
     if (!d_ptr->start()) {
+        qErrnoWarning("XX");
         fprintf(stderr, "The service %s could not start\n", serviceName().toLatin1().constData());
         return -4;
     }
