sandeep
sandeep

Reputation: 151

localsocket server not receiving readyread signal

I have a QLocalserver where I read data sent by a non QT client. The data is sent after receiving some keyevents. This means if I press some key, the data is sent through localsocket to server and I have to perform some action in my server.

Now it happens at times that the data does not reach the server even when the return value of sendto is +ve value i.e. success. The data is received only when any other key is pressed even though if I am not sending the data to socket after that.

I am reading for all bytes till end in while loop in my readyread slot, but stil don't know what the problem is. Can anyone help me in figuring this out. Is this related to ready read signal genration or some scheduling problem.

The Ready read slot is as below

void MainWindow::ReadyRead(void)
{
  char cmd[sizeof( struct Data)];
  struct Data *Rcv;
  while(ui->client->bytesAvailable())
  {
    ui->client->read(cmd, sizeof(struct Data));
    Rcv= ( struct Data *)cmd;
    CommandParser(Rcv);
  }
}

Upvotes: 0

Views: 255

Answers (1)

Robert
Robert

Reputation: 1343

W/o some piece of code it's hard to cleary say whats wrong, I've some assumptions:

  1. Since the data seems to be very small, it may be that the socket (client) is buffering the data up to a specific amount, thus not sent. See "Nagle"-algorithm...
  2. Do you have a endless-loop in your "readyRead"-slot? That could lead to problems while receiving the data.

A piece of code would be appreciated, though.

Upvotes: 0

Related Questions