C # peer-to-peer programming (preferably decentralized)

I am writing a content sharing application. You have a list of peers. You select several of them, and you can start sharing content (text and binary data). In the local network, if you enter the ip-address of other guys, the connection can go through.

I have a few questions

  • Is there any template for writing this type of chat application that can detect who is online and who is not (both local and online)? I know that this can be done with a centralized server, to which everyone connects, but what about decentralization, especially when you are on the local network.

  • When connecting to online clients, they usually do not have IP addresses, but rather lag behind the firewall, etc. Obviously, the IP address does not apply to the device, and some ports will be blocked. How does this happen?

PS: I read many stackoverflow pages on this subject. Some say it is possible, others say it is not. Now I’m really sure which one to take. Some even had information about C # bit torrent clients and servers. I am very open to suggestions while I can do this in .net. (C #, f #, vb all right)

Any suggestion would be greatly appreciated.

considers

+4
source share
2 answers

Opening means that one endpoint must be able to find other endpoints. On a local network, this is possible if broadcast (UDP) is allowed at the network level. A typical scenario is that the SNMP manager sends an SNMP GET message and sees how many SNMP responders on the same network respond. This is decentralized because there is no central registration location where a list of all endpoints is stored.

However, going beyond the LAN, there is no easy way, like broadcasting, to find other endpoints. Then a centralized solution is required.

Therefore, please additionally summarize the scenarios for your applications at all levels (application, network, etc.) to find out if a decentralized solution is available. In addition, when you read the conclusions of others somewhere, you should also pay attention to the special scenarios that he spoke about. These findings may only apply to these scenarios.

+1
source

If you want a central server (registration.mydomain.com), then one of the following solutions: 1. Peer-to-peer connections connect to the central server with the message "I'm here, here is my data." 2. The server records the IP address and port of the peer. 3. Peers requests a list of other peers from the server. 4. Peers are connected directly to other peers using the attached list.

Each peer must send updates to the server to indicate whether they are all there - or the server may try to connect to each peer (not always possible with all web servers) to determine the information itself.

Each peer also needs to periodically request a server for more peers in case any are connected or disconnected, although the latter is likely to be visible on your socket if you are not broadcasting.

0
source

Source: https://habr.com/ru/post/1387532/


All Articles