qt tcp client, C tcp server
Hi all,
I am writing a client/server application that is using Qt for its frontend and C for the server part. I am using Qt as it's rather easy to create a nice looking GUI and the C server does only do some very basic stuff(also I would like not to require the Qt libs on the servers). Can I just use the normal way that QT uses for creating a TCP client? Or does Qt do some special stuff in its classes that C might not be able to handle? Thanks in advance! |
Hi -
IMHO, qt doesn't have to do special stuff as a TCP client. Qt just uses the socket interface and the stack will take care of framing up TCP packets to your server. HTH! |
I used this example:
http://doc.qt.nokia.com/latest/netwo...uneclient.html But instead of using QDataStream I had to use QTextStream. And as I sent all lines with a newline character on the server side, i used in.readLine instead of in >> fortune. |
I recommend you create a header/source pair that provides an interface to set up I/O for the rest of the client. In the client, have a function that takes connection parameters and returns a QTextStream* (or whatever's appropriate for your I/O.) Since Qt has versions on things other than *nix, you might start with the "Qt way" of connecting in the source file. Since the interface in the header hides that, however, you'd be free to switch to the "*nix way", or even local sockets and named pipes, later on if you wanted to.
Kevin Barry |
All times are GMT -5. The time now is 09:28 AM. |