title: Client and Server in single file using socket in java
body: <p>Can anyone please tell me how to create a server and client (both) in a single file? </p>
  
  <p>I searched the net and came to know that it is possible using the threads. I am not familiar with threads. I am trying to implement a peer to peer application. At some point, the peer has to behave as server and client. Can anyone please give a sample code or direct me to a good source?</p>