1. Implementation
    1. protected: void incomingConnection(int socketDescriptor);
  2. void FortuneServer::incomingConnection(int socketDescriptor)
    1. FortuneThread *thread = new FortuneThread(socketDescriptor, fortune, this);
    2. connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
    3. thread->start();
  3. void FortuneThread::run()
    1. QTcpSocket tcpSocket;
    2. if (!tcpSocket.setSocketDescriptor(socketDescriptor)) { emit error(tcpSocket.error()); return;}
    3. Подготовка данных
      1. QByteArray block;
      2. QDataStream out(&block, QIODevice::WriteOnly);
      3. out <<
    4. tcpSocket.write(block);
    5. tcpSocket.disconnectFromHost();
    6. tcpSocket.waitForDisconnected()