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. Simple proxy, using two QTcpProxy
Forum Updated to NodeBB v4.3 + New Features

Simple proxy, using two QTcpProxy

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 5.0k Views 1 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.
  • D Offline
    D Offline
    DmT021
    wrote on last edited by
    #1

    Sorry for my bad English.
    I need to make a simple proxy (without auth, etc). Every connection must be in separated thread. It must transer data from/to browser and remote server.
    My variant looks like this:
    I have made a class Server (: QTcpServer), with overloaded incomingConnection
    When incomingConnection emitted, I create new object of class Transfer, which create a new thread.
    In new thread I create an object of class TransferHandler, which create two sockets(named in and out) and connect signals readyRead from in to slot inReadyRead, from out to outReadyRead. When these signals emited, I just copy data from one into another (using readAll()).
    When signals disconnected() emitted, I just close sockects an delete objects.
    In method run() of thread object I call method exec().

    Problem --
    Answers for all requests are come. But in the browser there is only a part of answer(I think only first package was come). Then, the browser hangs in connected state, but did not gets data.

    Source code:

    http://dl.dropbox.com/u/3506908/transfer/Transfer.h
    http://dl.dropbox.com/u/3506908/transfer/Transfer.cpp

    PS:--
    If try to transfer data without events(did not call exec()), but just in cycle and using waitForReadyRead() all data transfers in to browser/server, but there is very long ping.--

    1 Reply Last reply
    0
    • F Offline
      F Offline
      florent.revelut
      wrote on last edited by
      #2

      I went quickly through your code, some comments:

      • it's not useful to spawn a thread each time, you might want to keep working in the main thread and using just signals / slots (will work nicely unless you have to scale drastically)
      • as your transferhandler class is waiting on your socket, you'd rather connect signals and slots as son as you've created the objects (otherwise, you might lose some events)
      • you mix synchronous (waitForxxx) and asynchronous, it's not easy to follow

      So far, without compiling it, I didn't see any trivial issue, I might have a further look later.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DmT021
        wrote on last edited by
        #3

        Thanks, I'll rewrite code using only signals ans slots and paste sources here.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DmT021
          wrote on last edited by
          #4

          Ok. I've rewrote proxy.
          http://dl.dropbox.com/u/3506908/transfer/SimpleProxy.zip
          This archive contains a project, with partially working proxy. It works fine with GET reqests, but doesn't work with POST.
          I get "400 bad request", when uploading file. And http://ping.eu/ping/ also doesn't work.
          What is wrong?

          1 Reply Last reply
          0
          • D Offline
            D Offline
            DmT021
            wrote on last edited by
            #5

            Is anyone could answer me?

            1 Reply Last reply
            0
            • U Offline
              U Offline
              unmanner
              wrote on last edited by
              #6

              Hi All, and DmT021!

              I very-very interested in you QT proxy server! Could you please contact me here or by the mail: bushevuv@gmail.com

              If anyone knows someone about completed QT HTTP proxy server, please contack me :)

              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