LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-02-2011, 06:48 AM   #1
deadeyes
Member
 
Registered: Aug 2006
Posts: 609

Rep: Reputation: 79
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!
 
Old 09-02-2011, 07:26 AM   #2
hi2arun
Member
 
Registered: Apr 2010
Distribution: Fedora
Posts: 109
Blog Entries: 4

Rep: Reputation: 34
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!
 
Old 09-04-2011, 05:54 AM   #3
deadeyes
Member
 
Registered: Aug 2006
Posts: 609

Original Poster
Rep: Reputation: 79
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.
 
Old 09-04-2011, 10:23 AM   #4
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[Question] tcp client and server connection problems silentkill89 Programming 6 09-04-2011 08:27 PM
[SOLVED] How could server detect closed client socket using TCP and c++? Lobinho Programming 6 08-10-2010 02:28 PM
Tcp client server development ptlchetan Programming 4 09-15-2006 04:49 AM
Tcp/ip Client Server Problem tushar123 Programming 2 03-31-2004 05:16 PM
Server/Client-commucation via TCP-Sockets cYbORg Programming 5 05-18-2003 06:01 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration