Results 1 to 2 of 2

Thread: Implementing a TCP Server

  1. #1
    Join Date
    Aug 2012
    Qt products

    Default Implementing a TCP Server

    Can anyone tell me if I’m doing this right?

    Using Qt I’m implementing a TCP Server by inheriting from the QTcpServer class. On an incoming connection I create a new thread, a new Worker object, and I move the object to the new thread and start the thread. From here, the server keeps listening for new clients and each thread then is in its run method for object Worker.

    Now, I create a timer because I need to send updates to each client based on 1 second intervals AND when a song is playing. In the readyRead slot I read data using readAll and then perform some work and send a reply.

    However, when I go back to my run method I need to just continue sending song data updates to the clients (with no response from the client). Should this all just go in a while(true) loop and then I check some boolean to start and stop the timer? The track information I need to send is the song progression time.

    I guess my question is, should I be doing it this way? It seems a little complex, but then again that’s concurrency for you. Basically I need the TCP server to send data to the client repeatedly when some condition is true. I feel like just an endless while loop that checks when to start and stop the timer is useless work.

    Would posting code make this clearer?

  2. #2
    Join Date
    May 2012
    Thanked 27 Times in 24 Posts
    Qt products
    Qt3 Qt4 Qt5
    Unix/X11 Windows

    Default Re: Implementing a TCP Server

    What is the run method? And what data needs to be send at what time interval?

    some code would make it clearer.

Similar Threads

  1. [TCP Server] Server only sending when terminating
    By papperlapapp in forum Qt Programming
    Replies: 0
    Last Post: 6th December 2010, 20:41
  2. implementing 'scrollview'
    By rishiraj in forum Newbie
    Replies: 1
    Last Post: 18th December 2008, 13:23
  3. Implementing IME using QT
    By pmohod in forum Qt Programming
    Replies: 0
    Last Post: 16th February 2007, 13:22
  4. Implementing gif images in QT 3.3.2
    By vvbkumar in forum Qt Programming
    Replies: 3
    Last Post: 21st July 2006, 18:16

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.