Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. 2-way network communication between 2 Qt programs
QtWS25 Last Chance

2-way network communication between 2 Qt programs

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtnetworknetworkingc++tcpsockettcpserver
2 Posts 2 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    htmlboss
    wrote on 18 Jul 2016, 17:17 last edited by htmlboss
    #1

    Apologies for what probably is a noob (and long-winded) question, however this is my first time doing any kind of network programming (I'm very familiar with Qt and C++, but just not the TCP networking paradigm) so call me a dunce if you wish :P

    My scenario: I have 2 Qt applications (let's call them "node" and "controller"). There can only be one "controller", but the number of "nodes" may vary (eg. different clients). I want to have the "controller" initiate the connection to each client such that arbitrary data is sent back and forth as it is ready (readyRead() signal? ). I'm probably missing some important TCP concepts.

    I have implemented the Fortune Client/Server example with the "controller" as the Client (since it would initially ask for a connection), and the Fortune Server as a test (eventually it would be a "node" sending data). This is where I'm stuck. Ignoring less-than-critical performance issues, how would I modify the Fortune example (or perhaps roll my own) to allow the Server to accept data from the "controller" without the use of any buttons/etc, but to get it as it is "ready"? Ideally, this needs to scale up to a max of 15 "nodes".

    Please let me know if clarification is needed!

    K 1 Reply Last reply 18 Jul 2016, 20:20
    0
    • H htmlboss
      18 Jul 2016, 17:17

      Apologies for what probably is a noob (and long-winded) question, however this is my first time doing any kind of network programming (I'm very familiar with Qt and C++, but just not the TCP networking paradigm) so call me a dunce if you wish :P

      My scenario: I have 2 Qt applications (let's call them "node" and "controller"). There can only be one "controller", but the number of "nodes" may vary (eg. different clients). I want to have the "controller" initiate the connection to each client such that arbitrary data is sent back and forth as it is ready (readyRead() signal? ). I'm probably missing some important TCP concepts.

      I have implemented the Fortune Client/Server example with the "controller" as the Client (since it would initially ask for a connection), and the Fortune Server as a test (eventually it would be a "node" sending data). This is where I'm stuck. Ignoring less-than-critical performance issues, how would I modify the Fortune example (or perhaps roll my own) to allow the Server to accept data from the "controller" without the use of any buttons/etc, but to get it as it is "ready"? Ideally, this needs to scale up to a max of 15 "nodes".

      Please let me know if clarification is needed!

      K Offline
      K Offline
      kshegunov
      Moderators
      wrote on 18 Jul 2016, 20:20 last edited by
      #2

      @htmlboss
      Hi,

      let's call them "node" and "controller"

      Let's not do that. Let's call them a server and a client - it's much better and easier to follow the accepted terminology. A server will serve the requests presented by the clients (see the analogy with a busy restaurant?).

      There can only be one "controller", but the number of "nodes" may vary (eg. different clients).

      So you have one server and a few clients. So far so good.

      I want to have the "controller" initiate the connection to each client such that arbitrary data is sent back and forth as it is ready (readyRead() signal? ).

      How data flows between the client and the server is completely independent of who initiated the connection. You can still have the server sending data to the clients (what http servers mostly do), and still the client initiates the connection (i.e. your browser).

      I have implemented the Fortune Client/Server example with the "controller" as the Client (since it would initially ask for a connection), and the Fortune Server as a test (eventually it would be a "node" sending data). This is where I'm stuck. Ignoring less-than-critical performance issues, how would I modify the Fortune example (or perhaps roll my own) to allow the Server to accept data from the "controller" without the use of any buttons/etc, but to get it as it is "ready"? Ideally, this needs to scale up to a max of 15 "nodes".

      Just write from the appropriate side (application). The server should stay the server, and the client should stay a client, don't switch their roles.

      Kind regards.

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      2

      2/2

      18 Jul 2016, 20:20

      • Login

      • Login or register to search.
      2 out of 2
      • First post
        2/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved