I'd like to make a million dollars next week using only a can of dried tea leaves and some old newspaper. Please help me how to do this!
Um, no.

Start by browsing the JavaDocs of the java.net package, specifically java.net.Socket. You use a Socket to connect to a server (specifying IP address and port). Once connected, you can use the Socket's InputStream and OutputStream to send data to and retrieve data from the server.
The class is pertty easy to use as there's not much to it. Write a small program to
test what you've learned. The ServerSocket class allows you to create your own server.
Once you've gotten your feet wet with those, write up exactly what you want to do, try to do it, and
then come back here and post
specific questions about any troubles your having.
There's no way any human can possibly answer your open-ended question as is.