Hi,
I believe telnet uses TCP sockets for communication, therefore you can't use it to communicate with your program. The sample code I gave you uses UDP (Datagram) sockets. This is easier to use than TCP and should work fine when communicating over the same computer. I've never done socket programming in Java so I can't really help you that much.
Also, make sure you enable the reuse of an address by using the following command:
Code:
InSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
You should also do this within Java.