Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8956207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:44:18+00:00 2026-06-15T14:44:18+00:00

i am working on a project that requires tcp communication between a master application

  • 0

i am working on a project that requires tcp communication between a “master” application and a number of “servants”.
(the project is in c++ and i am also using qt)

The “servants” will do some processing and send their results to the “master”.
So far it’s a straightforward multi client-server app.

The thing is that at random times, the master will request some extra info from the servants, and even send them info to change the way they process.

if i base my project on the fortune client/server examples, will i be able to send messages to the servants from the master? (any ideas on how?)

or do i need to base my work on something else (like the chat client maybe?)?

any other suggestions on tcp client/server communication are welcome, but since i already use qt, i would prefer not to add other libs….

thank you in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:44:20+00:00Added an answer on June 15, 2026 at 2:44 pm

    To build a server in Qt is very simple. You have to derive QTcpServer and implement some methods or slot. This is valid for the clients too.
    Derive QTcpSocket and you will have your client.

    In example, to detect a client incoming you implement virtual void incomingConnection ( int socketDescriptor ). So in your case you can save clients incoming in a map (a map because every client will have its own id).

    In both server and client you will probably want to implement readyRead() slot.
    This slot do the communication thing that you want. In fact inside this slot the server can receive and send to client messages and vice-versa.

    This is a typical readyread :

      void Client::readyRead() {
         while (this->canReadLine()) {
                // here you get the message from the server
            const QString& line = QString::fromUtf8(this->readLine()).trimmed();
         }
     }
    

    this is how to send messages:

    void Client::sendMessage(const QString& message) {
        this->write(message.toUtf8());
        this->write("\n");
    }
    

    That’s all!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been working on a project that requires communication both directions between Java and
I am working on a project that requires some image processing. The front end
Currently am working on a project that requires me to create some XML for
I'm working on a project that requires a Web-based workflow application. We're now evaluating
I'm working on a project that requires me to load some of the data
I'm working on a project that requires developing an android application for a galaxy
I am working on a project that requires to autocomplete textbox when some data
I am working on a project that requires sandboxing an application. I am able
I am working on a project that requires some HTML sanitization. Normally, I would
Right now I'm working on a project that requires my application (C#) to connect

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.