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. can not send/receive data while client and server are running on two different PCs.
Forum Updated to NodeBB v4.3 + New Features

can not send/receive data while client and server are running on two different PCs.

Scheduled Pinned Locked Moved Unsolved General and Desktop
13 Posts 5 Posters 685 Views 2 Watching
  • 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.
  • J Offline
    J Offline
    jgxy1123
    wrote on last edited by
    #1

    Hello, All!

    I am writing an App using QTcpSocket and there are 3 steps of communications between the client and server.

    • first, client connects to server.
    • second, client sends file data to server.
    • third, server receives file data from client and feedback the write progress to client.

    The strange thing is that all these 3 steps above are working correctly when client and server are running on the same pc. however, the first step can work normally and the other remaining 2 steps does not work while client and server are running two different PCs.

    Is there anybody who has met the same problem?

    C jsulmJ 2 Replies Last reply
    0
    • J jgxy1123

      Hello, All!

      I am writing an App using QTcpSocket and there are 3 steps of communications between the client and server.

      • first, client connects to server.
      • second, client sends file data to server.
      • third, server receives file data from client and feedback the write progress to client.

      The strange thing is that all these 3 steps above are working correctly when client and server are running on the same pc. however, the first step can work normally and the other remaining 2 steps does not work while client and server are running two different PCs.

      Is there anybody who has met the same problem?

      C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      @jgxy1123 Platform? Windows firewall ports need to be open.

      J 1 Reply Last reply
      1
      • J jgxy1123

        Hello, All!

        I am writing an App using QTcpSocket and there are 3 steps of communications between the client and server.

        • first, client connects to server.
        • second, client sends file data to server.
        • third, server receives file data from client and feedback the write progress to client.

        The strange thing is that all these 3 steps above are working correctly when client and server are running on the same pc. however, the first step can work normally and the other remaining 2 steps does not work while client and server are running two different PCs.

        Is there anybody who has met the same problem?

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @jgxy1123 To add to @ChrisW67 : do you have any error handling to see what actually happens? With the information you provided only guessing is possible...

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

        J 1 Reply Last reply
        0
        • C ChrisW67

          @jgxy1123 Platform? Windows firewall ports need to be open.

          J Offline
          J Offline
          jgxy1123
          wrote on last edited by
          #4

          @ChrisW67 Yes, it is windows platform and I have closed the firewall itself totally, but it does not work either. If the client can connect to server , I think it is not the problem of firewall ,right? is there any other points I should check more?

          1 Reply Last reply
          0
          • jsulmJ jsulm

            @jgxy1123 To add to @ChrisW67 : do you have any error handling to see what actually happens? With the information you provided only guessing is possible...

            J Offline
            J Offline
            jgxy1123
            wrote on last edited by
            #5

            @jsulm Yes, everytime client gets message from server, I will let client print some message to debugging console.

            1. client connects to server, server send feedback to client ->OK
            2. client send user information to server, server send feedback to client->OK
            3. client send filename to server ,sever send feedback to client->OK
            4. server makes the file in the local folder and send feedback to client->OK
            5. client continuously sends the bytes of the file to server, server is supposed to receive the bytes and writes them to the local file of the server , but server can not receive any bytes of data->FAIL!!!!!!!
            JonBJ 1 Reply Last reply
            0
            • J jgxy1123

              @jsulm Yes, everytime client gets message from server, I will let client print some message to debugging console.

              1. client connects to server, server send feedback to client ->OK
              2. client send user information to server, server send feedback to client->OK
              3. client send filename to server ,sever send feedback to client->OK
              4. server makes the file in the local folder and send feedback to client->OK
              5. client continuously sends the bytes of the file to server, server is supposed to receive the bytes and writes them to the local file of the server , but server can not receive any bytes of data->FAIL!!!!!!!
              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #6

              @jgxy1123 Did you write the server side (as well as the client side)?

              J 1 Reply Last reply
              0
              • JonBJ JonB

                @jgxy1123 Did you write the server side (as well as the client side)?

                J Offline
                J Offline
                jgxy1123
                wrote on last edited by
                #7

                @JonB sorry, I don't undestand what you mean

                Pl45m4P 1 Reply Last reply
                0
                • J jgxy1123

                  @JonB sorry, I don't undestand what you mean

                  Pl45m4P Online
                  Pl45m4P Online
                  Pl45m4
                  wrote on last edited by Pl45m4
                  #8

                  @jgxy1123 said in can not send/receive data while client and server are running on two different PCs.:

                  sorry, I don't undestand what you mean

                  Are you coding the server app as well? Or only the client software? :)
                  (or at least have access to the server code)


                  If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                  ~E. W. Dijkstra

                  J 1 Reply Last reply
                  0
                  • Pl45m4P Pl45m4

                    @jgxy1123 said in can not send/receive data while client and server are running on two different PCs.:

                    sorry, I don't undestand what you mean

                    Are you coding the server app as well? Or only the client software? :)
                    (or at least have access to the server code)

                    J Offline
                    J Offline
                    jgxy1123
                    wrote on last edited by
                    #9

                    @Pl45m4 I am writing both of client and server. I have found that server can receive data normally when client sends a small size of bytes(e.g, 1byte or 1024 bytes) each time . But when the size of data is bigger than 10240 bytes or 65536bytes, server can only receive some portion of data or no data at all. I found that other people on the internet have met the similar problem and they sovelved by setting the header of each data package, so server can understand how to cut the data each time. Unfourtunately, I can hardly understand their codes and what they are saying.

                    So, Is there any better or easy way to solve this kind of problem using Qt library or API ?

                    Pl45m4P JonBJ 2 Replies Last reply
                    0
                    • J jgxy1123

                      @Pl45m4 I am writing both of client and server. I have found that server can receive data normally when client sends a small size of bytes(e.g, 1byte or 1024 bytes) each time . But when the size of data is bigger than 10240 bytes or 65536bytes, server can only receive some portion of data or no data at all. I found that other people on the internet have met the similar problem and they sovelved by setting the header of each data package, so server can understand how to cut the data each time. Unfourtunately, I can hardly understand their codes and what they are saying.

                      So, Is there any better or easy way to solve this kind of problem using Qt library or API ?

                      Pl45m4P Online
                      Pl45m4P Online
                      Pl45m4
                      wrote on last edited by Pl45m4
                      #10

                      @jgxy1123 said in can not send/receive data while client and server are running on two different PCs.:

                      But when the size of data is bigger than 10240 bytes or 65536bytes, server can only receive some portion of data or no data at all

                      So exactly 10 kB and 64 kB?!

                      Have you seen this?

                      • https://stackoverflow.com/questions/20546750/qtcpsocket-reading-and-writing

                      Or this

                      • https://github.com/manfredipist/QTcpSocket

                      server can only receive some portion of data or no data at all

                      What do you do exactly?

                      Unfourtunately, I can hardly understand their codes and what they are saying

                      If you dont understand how to do it and dont understand the code, start to learn :) Or move to some easier task

                      So, Is there any better or easy way to solve this kind of problem using Qt library or API ?

                      No API or Qt will manage how or when to send any raw data. This is up to you and you also need to handle it.
                      QTcpSocket for example, tells you, when data was send or arrived or throw an error if any. Whether you send chunks of garbage, Qt cant tell ;-)


                      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                      ~E. W. Dijkstra

                      J 1 Reply Last reply
                      0
                      • J jgxy1123

                        @Pl45m4 I am writing both of client and server. I have found that server can receive data normally when client sends a small size of bytes(e.g, 1byte or 1024 bytes) each time . But when the size of data is bigger than 10240 bytes or 65536bytes, server can only receive some portion of data or no data at all. I found that other people on the internet have met the similar problem and they sovelved by setting the header of each data package, so server can understand how to cut the data each time. Unfourtunately, I can hardly understand their codes and what they are saying.

                        So, Is there any better or easy way to solve this kind of problem using Qt library or API ?

                        JonBJ Offline
                        JonBJ Offline
                        JonB
                        wrote on last edited by
                        #11

                        @jgxy1123
                        Everything @Pl45m4 has said. Since you are writing the server maybe your server-side code is wrong for receiving the data. We don't know how you judge "server can only receive some portion of data or no data at all".

                        J 1 Reply Last reply
                        0
                        • Pl45m4P Pl45m4

                          @jgxy1123 said in can not send/receive data while client and server are running on two different PCs.:

                          But when the size of data is bigger than 10240 bytes or 65536bytes, server can only receive some portion of data or no data at all

                          So exactly 10 kB and 64 kB?!

                          Have you seen this?

                          • https://stackoverflow.com/questions/20546750/qtcpsocket-reading-and-writing

                          Or this

                          • https://github.com/manfredipist/QTcpSocket

                          server can only receive some portion of data or no data at all

                          What do you do exactly?

                          Unfourtunately, I can hardly understand their codes and what they are saying

                          If you dont understand how to do it and dont understand the code, start to learn :) Or move to some easier task

                          So, Is there any better or easy way to solve this kind of problem using Qt library or API ?

                          No API or Qt will manage how or when to send any raw data. This is up to you and you also need to handle it.
                          QTcpSocket for example, tells you, when data was send or arrived or throw an error if any. Whether you send chunks of garbage, Qt cant tell ;-)

                          J Offline
                          J Offline
                          jgxy1123
                          wrote on last edited by
                          #12

                          @Pl45m4

                          Thank you so much!
                          The first link helped me solve the problem ^_^

                          1 Reply Last reply
                          1
                          • JonBJ JonB

                            @jgxy1123
                            Everything @Pl45m4 has said. Since you are writing the server maybe your server-side code is wrong for receiving the data. We don't know how you judge "server can only receive some portion of data or no data at all".

                            J Offline
                            J Offline
                            jgxy1123
                            wrote on last edited by
                            #13

                            @JonB

                            Thank you for your help!
                            The problem was caused by the lack of my basic understanding of QTcpSocket and I will study harder ^_^

                            1 Reply Last reply
                            0

                            • Login

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