Is it possible to code an application that can detect and connect to peers without a central server? How?

144 views Asked by At

Is it possible to code an application that can detect and connect to peers without a central server? How?

I believe this is what some peer-to-peer applications do, but my knowledge in programming is much better than in networking.

Let's say you want to create a private chat application that works the following way:

  1. You define a list of IDs you trust
  2. The application displays all the peers that have the same application and have a trusted ID
  3. You establish a connection that allow you to chat and send small documentations (source code, odt files, etc.) without the need to open a port in the router.

I'm not, of course expecting, a silver bullet answer, just some clues of the feasibility, and the technologies this would require.

1

There are 1 answers

0
H Aßdøµ On

That is depend in what type of network your application going to run in to, for LAN networks, you can do this:

  • Client(or peeer) sends a broadcast in LAN in order to get list of available peers.
  • Other online peers will respond to the IP of this peer broadcast, like this: I am peer ID: xxx, and my ip address is 192.168.1.44, with listening port on 4567.
  • Now the peer has the list of available connected peers.

Of course, you have to design a broadcast protocol to get list of available peers. A simple broadcast protocol could have the following options: The IP address of peer who queried for available peers, so others will respond to this IP, port number of broadcast protocol. The available peers will respond with this information: IP address, port number of the chat application. Now the chat application can use this information to connect with those peers. This will apply for LAN networks, but to identify peers on internet I didn't find a solution with out relying on central server.

Sorry for my English, and I hope at least you have an idea now.