Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Some communications are lost, when many small data is send
QtWS25 Last Chance

Some communications are lost, when many small data is send

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 558 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    curator
    wrote on last edited by
    #1

    Hi again,

    during the last days I started to implement some TCP communication with the help of this Forum. Again, let me thank you very much for your help.

    Lets assume QTCPServer and QTCPSocket are connected and on the Server side, the incomming connecting socket ist stored as m_currentClient and a function startRead() is connected with the "readReady" Signal.

    My Server has many data, on which it does some fancy computations. The results are again many data segments, which has to be communicated to the Client = GUI.

    Ok, my idea is to send a unique QString identifier, that tells the Server what he has to do. This concept worked up to now, but now, i have to read more than 20 values, but that doesn't work anymore.
    Here is my small example

    @
    Client:
    for (unsigned int i=0;i<N;++i)
    {
    write("GIVEDATA\n"); // some unique identifier

     QByteArray p_ByteArray;
     QDataStream p_DataStream(&p_ByteArray, QIODevice::ReadWrite);
     p_DataStream << i_RoomID << i_WallID; // send two ints
     write(p_ByteArray);
    
     // wait for result
     waitForReadyRead();
    
     QByteArray p_ByteArray2;
     QDataStream p_DataStream2(&p_ByteArray2, QIODevice::ReadWrite);
     p_ByteArray2 = readLine();
    
    
     float p_Data;
     p_DataStream2 >> p_Data;
    
     printf("%d: %4.2f\n",i,p_Data); // First about 15 are correct, the zeros start to occur inbetween
    

    }

    Server:
    startRead()
    {
    QString p_Line;

     p_Line = QString::fromUtf8(m_currnetClient->readLine()).trimmed();
    
     if(p_Line.mid(0,8)=="GIVEDATA")
     {
          QByteArray p_ByteArray;
          QDataStream p_DataStream(&p_ByteArray, QIODevice::ReadWrite);
          p_ByteArray = m_currnetClient->readLine();
    
          int p_RoomID, p_WallID;
          p_DataStream >> p_RoomID >> p_WallID;
    
          QByteArray p_ByteArray2;
          QDataStream p_DataStream2(&p_ByteArray2, QIODevice::ReadWrite);
    
          p_DataStream2 << myData[p_RoomID][ p_WallID];     // std::vector<std::vector<float>>;
          m_currnetClient->write(p_ByteArray2);
     }
     else if ....
     else
          printf("I dont know what to do");
    

    @

    So thats the Code. The first values are correct, then some Zeros start to get read. Again, for a small amount of data it works, but more more data the communication seems to Clip or sth.

    Does anyone have an idea where to start.

    I have both Server and Client on the some Computer both with visual Studio an was in debug mode on both applications. I debuged from step to step and found out that the correct data is brougt to the stream, but the wrong data is received. Really strange .....

    Kind regards,
    curator

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved