title: How to build a simple peer-to-peer system in Java?
body: <p>I am doing an university project. I need some sample programs on peer to peer programs in Java socket programming. Everywhere people are saying to add a server socket in the client program.</p>
  
  <p>Would a single program having server socket and client socket do or do I have to create two programs of one initiating a system and another peer program running thrice to solve the problem?</p>
  
  <p>I know how to do a socket program for client server model and clear on the concept. But creating a peer to peer architecture sounds complex for me to understand.</p>
  
  <p>I also referred to <a href="https://stackoverflow.com/questions/4920527/developing-peer-to-peer-application-in-java">this thread</a>.</p>
  
  <p>The person commented second says "To make peer2peer app each client opens server socket too. When client A wishes to connect to client B it just connects to its socket".</p>
  
  <p>Need some more sample and an explanation on how peer to peer Java socket program works. I don't want any external API like jxta to do this task. I need a clear picture on how it works.</p>