There is some general client and server code in the following libraryhttp://www.scottshaver2000.com/template/template.php?page=planetation_main
Take a look at the code in the com\sas\util\socket, com\sas\planetation\clients and com\sas\planetation\servers packages. This is the old way to do things the new NIO packages allow for better scaling.
Works something like this:
1> Start server listening thread, listens for connections on specified port.
2> When a client connects spawn a new thread to handle that clients connection
3> goto 1