0
votes

Is it possible to read unknown form of data from a QTcpSocket ?

I mean, I have a TCP client and server application. Both are using QDataStream to exchange the data packets successfully.

If say any other application (not created be me) sends data thru the same IP and port to my server, is it possible to read the data ?

I know that unless it's written using QDataStream, it won't be possible to read it, but how do I dump the receiving data so that I can change my code to accept that form of data ?

So, finally my question, how can a server/client application using QTcpSocket read (dump) data from an unknown client/server application ?

Hope I didn't confuse anyone.

1
If you want to handle plain data, do not use QDataStream, but read() directly.Frank Osterfeld
how to determine what types of data is being received ? Is there any functionality to check it ?Anon
No, how to interpret the data is protocol-specific and up to youFrank Osterfeld

1 Answers

0
votes

I think the issue is that you're reading with a QDataStream, not that you're using a QTcpSocket. In that case, use readRawData. This will ignore the formatting expected by QDataStream.

http://qt-project.org/doc/qt-4.8/qdatastream.html#readRawData