Client 2 client communication



  • Hello everybody,

    I have a theoretically oriented question. I have a client-server architecture and I want to establish a communication between clients directly (I expect big amount of data). What would you recommend to use? How would you solve this problem, because I've tried a lot of possibilities in Qt and none was successfull. I'm intrested mostly in some general advice, how to establish connection, what informations do I want to exchange due to private addresses and NAT (If my clients had public addresses, than I would use a static port number instead)

    Thank you for any advices
    Miroslav Jaros

    PS: please excuse my english, I'm not a english speaking person



  • Your "clients", are they running on the same computer?

    If so, have a look at QSharedMemory and QSystemSemaphore classes!

    Otherwise, the QtNetwork module is your friend...



  • Hello,

    No they are not, I didn't made myself clear, I'm writing a network application, and I'm already using QtNetwork module, the Client->Server communication works well, because the server has a public address, but I want to establish a network communication between clients, and I don't know what informations do I need to establish connection between them using a server. (meaning TCP connection)



  • Well, usually one Client opens a Socket and "listens" for incoming connection, then the other Client can connect to that Socket. For this, the second Client needs to know the IP-Address (or DNS-Name) of the first Client as well as the Port-Number where the first Client is listening.

    If you want your Clients to connect with the help of a Server, the Server must have a known IP-Address (DNS-Name) and it must be listening on a known Port-Number. Then both Clients can connect to that Server. Now the Server can maintain a DB where it keeps the info (IP-Address + Port Number) of each Client. It can also forward that info the all other Clients on request, so Clients can now make direct connections, as described in first paragraph.

    NOTE: If any of the Clients is behind a NAT router, that Client cannot accept incoming connections, except by re-configuring the NAT router ("Port Forwarding" aka "Virtual Server"). But it can still connect to another Client that is listening (i.e. one side is not behind a NAT router). If both Clients are behind a NAT router, you need to use tricks like "TURN":http://en.wikipedia.org/wiki/Traversal_Using_Relays_around_NAT.

    See also:
    [url]http://qt-project.org/doc/qt-5.0/qtnetwork/examples-network.html[/url]


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.