Introduction | Setup | Peer | Server | Centralised | DHT | Presentation | Architecture-Basic | Architecture-Operation |
The first use of this set of programs is to create a P2P Chat System. Although the system is essentially P2P, it does use a server to relay information ABOUT each peer to each other during the initial connection phase. This is known as a Centralised P2P System.
When a peer first connects to the system, it registers via the server. This server then adds this new peer to its global peer list (containing vital connection details such as the IP address and port of the peer) and then distributes the new peer list to every peer currently in the system.
Once a peer receives this list of peers from the server, it becomes aware of all of the other peers in the system and then can directly send message packets to other peers and essentially "chat" to each other.
This is essentially the spirit of Centralised P2P. A server is used to pull together peers and allow them to learn about each other however, the majority of the workload (the actual messaging between peers) does not require any assistance from the server. This method stands in contrast to a Client-Server model where a server would relay messages between clients.
The following demo will instruct you on how to use the P2P Peer and Server applications to create a small example of a centralised system on a single local machine.
NOTE: If you are planning to run multiple instances of the P2P Peer to connect with each other, it is recommended that you make a copy of the entire ChatClient program (as many as are needed) and run it from there. The programs log all their network traffic in a file titled "log.txt" which can cause I/O issues when multiple instances of the program try to edit the same file.