1

I need to make peer-to-peer communication between applications.

The applications also shall find each other automatically in internet. For this, among other things, I need to overcome NAT Traversal, etc.

As example, I need to use the communication something like following:

InternetPeer peer;

peer.setName("my_name");

peer.listen(); // accept connections
peer.startSearchForOthers(); // find another peers

connect(&peer, &InternetPeer::newConnection, this, ...);

connect(&peer, &InternetPeer::anotherPeerFound, this, ...);

QStringList peerNames = peer.availablePeers();

peer.sendMessage(peerNames.at(0), "Hello");

peer.close();

Then it would be good to have some way to access such a connection with QTcpSocket or QUdpSocket.

How this can be done on Qt and c++?

Vladimir Bershov
  • 2,701
  • 2
  • 21
  • 51
  • Start with a simpler project. Write some code to have two copies of your app exchange messages. You can find a sample QT chat app online which will help you understand the processes. – john elemans Dec 17 '19 at 22:19
  • @johnelemans I know about Qt chat examples, but have no adea how to connect over internet – Vladimir Bershov Dec 17 '19 at 22:44
  • The problem here is really the p2p part rather than anything to do with Qt. To that end you might want to look at using an IP multicast announce/discover mechanism such as [avahi](https://www.avahi.org/). – G.M. Dec 18 '19 at 09:37
  • Look more closely, if you set up a chat over IP then just use a remote IP address. Same thing! – john elemans Dec 18 '19 at 17:56

0 Answers0