I now I should receive the data and transform the various records into (string, int, float etc) but I don't know how to do it, can you help me?
Your readClient() method is not very robust.
If you receive the block size but not enough data to read the block then your method will interpret the next data as the next block size when new data arrives.
You need to remember which state of the reading/decoding process you are in.
As for sendToClient(): why do you write a string and not also use QDataStream?
can you explain yourself better? I Send QbyteArray.
Right, sorry, got confused by the toString() calls.
What you are looking for is to use the actual column data type instead of converting each field to string.
Otherwise you have to parse the strings at the client side.
Last edited by Nio74; 13th March 2019 at 07:09.
The "shift" operators (<< and >>) of QDataStream have several overloads.
could someone give me a small example?
QDataStream have operators << and >> for for all basic data types.
Thanks for your patience. Then it would be better if I extract all the server data I insert myself into variables and send them directly to clients without going through QbyteArray? Afterwards in the Client can I receive them separately?
The important part is to convert the values from the query into the actual data type before writing into the data stream.
You likely also want a "header" like in the other direction, e.g. a number that indicates the size of the message to wait for before decoding.
Last edited by Nio74; 13th March 2019 at 10:26.
should I always use the QByteArray for send data at client?
Last edited by Nio74; 13th March 2019 at 13:29.
Second socket is only a pipe. You can not guarantee that one socket.write () operation corresponds to one socket.read () operation. You must provide logic that will pick up the packets of bytes correctly, glue them and interpret them.
I did not use the Qbuffer because on the client I am not able to integrate it, but if I use it on the server side and on the client no the data is received the same. How does it look? We accept suggestions!
can`t read a binary data!