TCP Peer to Peer chat application using java

I want to make a simple Peer To Peer Chat Application (without UI, command line is enough) using Java. For this application, both the client and the server should be in a single file.

When given a port number and an IP address, a socket connection is to be established and both the peers should be able to chat.

Can anyone help me out with this?

Thanks in advance