I understand that you are looking for code directly... but I'd recommend you try doing it by yourself.. here are the hints.
1) ServerSocket is a
java class which can create a socket (IP/Port combination) in the server, and keep listening for incoming packets.
2) Socket is another java class which can communicate to any other socket or serversocket.