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. Qtcpserver listening on multiple ports
Forum Updated to NodeBB v4.3 + New Features

Qtcpserver listening on multiple ports

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 2.0k 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.
  • B Offline
    B Offline
    bharathballa
    wrote on last edited by
    #1

    hello,
    I am a beginner to Qt.
    basically in my application i had 5 Pc's. one will act as server and all the others acts as clients. my requirement is to connect to those 4 Client pcs to the server pc. in my code i called listen function 4 times with ifferent ports and in my client applications i took 4 different ports to connect to server pc.
    but it is not happening. please help. how to do that```

    in my server code i implemented as follows
    //
    server-> listen(hostaddress,1232);
    server-> listen(hostaddress,1233);
    server-> listen(hostaddress,1234);
    server-> listen(hostaddress,1235);

    
    so i thought the server will listen to multiple clients. but it is listening on on the last line i.e on 1235 port
    please help me how to do that. thanks in advance
    T aha_1980A 2 Replies Last reply
    0
    • B bharathballa

      hello,
      I am a beginner to Qt.
      basically in my application i had 5 Pc's. one will act as server and all the others acts as clients. my requirement is to connect to those 4 Client pcs to the server pc. in my code i called listen function 4 times with ifferent ports and in my client applications i took 4 different ports to connect to server pc.
      but it is not happening. please help. how to do that```

      in my server code i implemented as follows
      //
      server-> listen(hostaddress,1232);
      server-> listen(hostaddress,1233);
      server-> listen(hostaddress,1234);
      server-> listen(hostaddress,1235);

      
      so i thought the server will listen to multiple clients. but it is listening on on the last line i.e on 1235 port
      please help me how to do that. thanks in advance
      T Offline
      T Offline
      Tirupathi Korla
      wrote on last edited by Tirupathi Korla
      #2

      @bharathballa

      You don't need to create four different ports to connect to a server. As server can serve multiple clients at the same time, you can connect to multiple clients with same port.

      1 Reply Last reply
      3
      • B bharathballa

        hello,
        I am a beginner to Qt.
        basically in my application i had 5 Pc's. one will act as server and all the others acts as clients. my requirement is to connect to those 4 Client pcs to the server pc. in my code i called listen function 4 times with ifferent ports and in my client applications i took 4 different ports to connect to server pc.
        but it is not happening. please help. how to do that```

        in my server code i implemented as follows
        //
        server-> listen(hostaddress,1232);
        server-> listen(hostaddress,1233);
        server-> listen(hostaddress,1234);
        server-> listen(hostaddress,1235);

        
        so i thought the server will listen to multiple clients. but it is listening on on the last line i.e on 1235 port
        please help me how to do that. thanks in advance
        aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by aha_1980
        #3

        Hi @bharathballa,

        please have a look at the examples: http://doc.qt.io/qt-5/examples-network.html

        As already said, you only need to listen on one port.

        Qt has to stay free or it will die.

        1 Reply Last reply
        2

        • Login

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