Dear All,

Am working on Server and Socket project. I want both of the server and socket talk to each other, meaning writing and reading! However, its not working! I tried the socket writing to the server, and it works great! But the server writing to the client is not working!! wat i am missing here

Server Code:

Qt Code:
  1. ServerOne::ServerOne(QObject* parent) : QObject(parent) {
  2. connect(&m_TcpServer8000, SIGNAL(newConnection()), this, SLOT(acceptLegacyDLIConnection()));
  3. timer = new QTimer();
  4. //here i define the signal slot of the server writing to the socket
  5. connect(timer, SIGNAL(timeout()), this, SLOT (handleWrite()));
  6. }
  7.  
  8. ServerOne::~ServerOne() {
  9. }
  10.  
  11. //accepts the incoming connection
  12. void ServerOne::acceptLegacyDLIConnection(){
  13. m_TcpSocket8000 = m_TcpServer8000.nextPendingConnection();
  14. connect(m_TcpSocket8000, SIGNAL(readyRead()), this, SLOT(handleRead()));
  15. timer->start(4000);
  16. }
  17.  
  18. //handles the incoming data from the socket
  19. void ServerOne::handleRead(){
  20. }
  21.  
  22. //handles the write to the client socket
  23. void ServerOne::handleWrite(){
  24. m_TcpSocket8000->write("In the server and writing to the client..");
  25. qDebug() << "writing..";
  26. }
To copy to clipboard, switch view to plain text mode 

Client Side:

Qt Code:
  1. Client::Client(QObject* parent) :
  2. QObject(parent) {
  3. connect(client8000, SIGNAL(connected()), this, SLOT(handleWrite()));
  4. timer = new QTimer(this);
  5. connect(client8000, SIGNAL(readyRead()), this, SLOT(handleRead()));
  6. }
  7.  
  8. Client::~Client() {
  9. }
  10.  
  11. //connects the socket to the server and starts timer to send continous msgs to server
  12. void Client::connectToServer(QString address, quint16 port) {
  13. QHostAddress addr(address);
  14. client8000->connectToHost(addr, port);
  15. connect(timer, SIGNAL(timeout()), this, SLOT(handleWrite()));
  16. timer->start(2000);
  17. }
  18.  
  19. // handles the writing to server
  20. void Client::handleWrite() {
  21. }
  22.  
  23. //handles the incoming data from server
  24. void Client::handleRead() {
  25. char buffer [1024] = {0};
  26. client8000->read(buffer, client8000->bytesAvailable());
  27. cout << buffer << endl;
  28. }
To copy to clipboard, switch view to plain text mode