Conventional UNIX Socket based server receiving data from QTcpSocket... Possible?
I am working on a pair of applications that serve different system needs. The client application I have written in Qt since QWT is key though for the server, I wish to write it in standard C++ (There are circumstances that make this is preferable).
My question is simply, how best to send data from the Qt client using QTcpSocket in such a way that it is directly readable by a non Qt socket?
Thank you, I appreciate any time spent in providing insight.
Re: Conventional UNIX Socket based server receiving data from QTcpSocket... Possible?
I might be wrong, since I'm new to Qt and never used one of it's QSockets, but I imagine that data is data.
What I mean is, if you make a tcp connection with QTcpSocket and send 8 bytes of data, the other side will recieve 8 bytes of data, untouched.
I think you do not need to worry, it's a convenience class around sockets.
regards,
hexa
Re: Conventional UNIX Socket based server receiving data from QTcpSocket... Possible?
Quote:
Originally Posted by
hexa
but I imagine that data is data.
Oops :-)
Data can take a billion and one forms.
If your unix socket uses UDP and you send data via TCP, I think you might have a problem.
So, this only works if both sockets speak the same "language".
Re: Conventional UNIX Socket based server receiving data from QTcpSocket... Possible?
Quote:
Originally Posted by
tbscope
If your unix socket uses UDP and you send data via TCP, I think you might have a problem.
There will be no problem. There will simply be no communication as UDP and TCP have their own set of ports so UDP port X has nothing to do with TCP port X. There can be different services running on both of them.
Re: Conventional UNIX Socket based server receiving data from QTcpSocket... Possible?
Quote:
Originally Posted by
Gavin Harper
My question is simply, how best to send data from the Qt client using QTcpSocket in such a way that it is directly readable by a non Qt socket?
As long as you send the data using whatever format the other end requires then all will be good. If it is text data then this fairly trivial, if it is binary then you need to send it using the lower level QIODevice::write() interface. Do not use QDataStream unless you have a Qt receiver.
Re: Conventional UNIX Socket based server receiving data from QTcpSocket... Possible?
Quote:
Originally Posted by
ChrisW67
As long as you send the data using whatever format the other end requires then all will be good. If it is text data then this fairly trivial, if it is binary then you need to send it using the lower level
QIODevice::write() interface. Do not use
QDataStream unless you have a Qt receiver.
That is exactly what I needed to know! Thank you!
I was concerned that my current method of using QByteArray's and QDataStreams would render the packets incompatible.
Re: Conventional UNIX Socket based server receiving data from QTcpSocket... Possible?
QByteArray is fine. QDataStream has an algorithm within so you need to implement the same algorithm without Qt if you want to use it with a different technology.
Re: Conventional UNIX Socket based server receiving data from QTcpSocket... Possible?
So if I use QByteArray and fire that out over QTcpSocket, it can be interpreted by a standard non-Qt socket bound to a given port?
I will just (generally) be sending floating point numbers.
I need my Client application to be Qt for cross platform compatibility but the server is likely to run on a UNIX based OS with no guarantee that Qt will be available.
Thank you to everyone thus far for help!
Re: Conventional UNIX Socket based server receiving data from QTcpSocket... Possible?
QByteArray is just a series of bytes without any modifications.