Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Host QT TCP Server

    General and Desktop
    2
    6
    243
    Loading More Posts
    • 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.
    • D
      Debson last edited by

      Hi,

      I have understanding how to create TCP server, client and communicate between them. Unfortunately I can't find an answer on how can I host my TCP server so it can be accessed by any computer in the Internet running my client app. Is there any tutorial that shows how to host a QT TCP server(e.g. on Digital Ocean)? Can I just change TCP server IP to my Digital Ocean server's IP, upload TCP server executable and run it on the Digital Ocean server or it's a big misconception?

      Thanks.

      jsulm 1 Reply Last reply Reply Quote 0
      • jsulm
        jsulm Lifetime Qt Champion @Debson last edited by

        @Debson No, your understanding is correct. You need to deploy your server part to your server and run it there. Your clients need to know the server IP (and port) to be able to connect. Make sure the firewall on the server is not blocking the port where your server app is listening for connections.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 3
        • D
          Debson last edited by

          That's great. Thank you so much for that answer.
          Since I have created this topic I have one more question. Is it a common practise for applications that need to access data stored on a server side(in SQL file) to use TCP server/client approach?
          E.g. Chat application where TCP server redirect message sent by one client to another client.
          Maybe there is a different approach for this type of applications that I'm not aware of?

          Thanks

          jsulm 1 Reply Last reply Reply Quote 0
          • jsulm
            jsulm Lifetime Qt Champion @Debson last edited by jsulm

            @Debson Well, yes you have to use TCP/IP if you want to communicate over network. Often databases are hidden behind an REST API, so the applications do not use SQL directly but this interface to access data in databases. Reason is that exposing SQL servers to the Internet is a bad idea because of security issues these server often have.
            "Maybe there is a different approach for this type of applications that I'm not aware of?" - see https://en.wikipedia.org/wiki/Peer-to-peer for an alternative approach.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply Reply Quote 4
            • D
              Debson last edited by

              Its means that if I want to keep database of users and their data it will be better, more secure and common way to access that information through REST API from HTTP server instead of using sockets for communication?

              jsulm 1 Reply Last reply Reply Quote 0
              • jsulm
                jsulm Lifetime Qt Champion @Debson last edited by

                @Debson I would say yes. But my understanding was that you wanted to expose SQL database directly to the Internet. This is what you should not do. You can use sockets to communicate between client and server to have a "light" interface as REST is based on HTTP and brings some overhead.

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply Reply Quote 5
                • First post
                  Last post