#ifndef GREETER_H #define GREETER_H #include #include #include class Greeter : public QObject { Q_OBJECT public: Greeter(QObject *parent) : QObject(parent) {} public slots: void newConnection(QObject* serverObject) { QTcpServer* server = static_cast(serverObject); QTcpSocket* connection = server->nextPendingConnection(); connect(connection, SIGNAL(disconnected()), connection, SLOT(deleteLater())); QHostAddress peerAddress = connection->peerAddress(); QString address = peerAddress.toString(); connection->write("Hello "); connection->write(address.toAscii()); connection->write("\n"); connection->disconnectFromHost(); } }; #endif