I did a Java program that basically implemented a sort of chat between a client and a server. Used a socket to open up a port of the server that would hear incoming connections. You should have a thread hearing them and calling actions when ever a valid connection would come in.