After searching in this Qt Forum, I made attempt to write data on server by using below mentioned code, but it was not working.
Qt Code:
  1. void Server::writetoallclients()
  2. {
  3. QString Data="2allclients";
  4. foreach(QtcpSocket *socket,socket)
  5. {
  6. socket->write(Data.toUtf8().constData());
  7. qDebug("data sent to all Clients");
  8. }
  9. }
To copy to clipboard, switch view to plain text mode 
Qt Code:
  1. void Client::read()
  2. {
  3. qDebug("start reading the socket");
  4. QByteArray buffer= socket->readLine();
  5. qDebug("data rxcd from server ");
To copy to clipboard, switch view to plain text mode