Hello, i got stuck while trying writing to a threaded server. Receiving works fine but the other way around...
Method readData() at tcpsocket.cpp is never called. What am I doing wrong?

Server:

Qt Code:
  1. MultiServer server;
  2. if (!server.listen(QHostAddress::Any, 15000)) {
  3. close();
  4. return;
  5. }
To copy to clipboard, switch view to plain text mode 

multiserver.cpp
Qt Code:
  1. MultiServer::MultiServer(QObject *parent)
  2. : QTcpServer(parent)
  3. {
  4.  
  5. }
  6.  
  7. void MultiServer::incomingConnection(int socketDescriptor)
  8. {
  9. QString msg = "Message from server";
  10. ConnectionThread *thread = new ConnectionThread(socketDescriptor, msg, this);
  11. connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
  12. thread->start();
  13. }
To copy to clipboard, switch view to plain text mode 

connectionthread.cpp
Qt Code:
  1. ConnectionThread::ConnectionThread(int socketDescriptor, const QString &msg, QObject *parent)
  2. : QThread(parent)
  3. , socketDescriptor(socketDescriptor)
  4. , text(msg)
  5. {
  6.  
  7. }
  8.  
  9. void ConnectionThread::run()
  10. {
  11. my_sock = new CTcpSocket(socketDescriptor);
  12.  
  13. my_sock->writeData(text);
  14. }
To copy to clipboard, switch view to plain text mode 

tcpsocket.cpp
Qt Code:
  1. CTcpSocket::CTcpSocket(int socketDescriptor, QObject *parent)
  2. : QObject(parent)
  3. , m_socketDescriptor(socketDescriptor)
  4. {
  5. m_tcpSocket = new QTcpSocket();
  6.  
  7. if (!m_tcpSocket->setSocketDescriptor(m_socketDescriptor)) {
  8. qDebug() << m_tcpSocket->error();
  9. return;
  10. }
  11.  
  12. [COLOR="Red"]connect(m_tcpSocket, SIGNAL(readyRead()), SLOT(readData()));[/COLOR]
  13. }
  14.  
  15.  
  16. [COLOR="Red"]void CTcpSocket::readData()
  17. {
  18. //ToDo Implement reading Data
  19. qDebug() << "try to read";
  20. //m_tcpSocket->waitForReadyRead(10000);
  21. }[/COLOR]
  22.  
  23.  
  24. void CTcpSocket::writeData(QString txt)
  25. {
  26. qDebug() << "try to write";
  27.  
  28. QByteArray block;
  29. QDataStream out(&block, QIODevice::WriteOnly);
  30. out.setVersion(QDataStream::Qt_4_0);
  31. out << (quint16)0;
  32. out << txt;
  33. out.device()->seek(0);
  34. out << (quint16)(block.size() - sizeof(quint16));
  35.  
  36. m_tcpSocket->write(block);
  37.  
  38. m_tcpSocket->waitForBytesWritten(10000);
  39.  
  40. m_tcpSocket->disconnectFromHost();
  41. m_tcpSocket->waitForDisconnected();
  42. }
To copy to clipboard, switch view to plain text mode