If you use an applet you won't be communicating with anything but the server, since the security restrictions keep you from connecting to anywhere but the server that the applet is downloaded from. Applets aren't useful for peer to peer.
The Java Tutorial has plenty of information on how to setup sockets as a server.
The Java TutorialThere is also information about threads contained in the tutorial.
Typically if you are going to be using a socket to communicate with a server for a game you will want to create your socket and use a thread to send/receive the information for that socket. The Observer and Observable classes are useful for this, you can find a tutorial on how to use observer and observable online at
javaworld.