Search code examples
javatelnet

How to Invoke Telnet communication using Java sockets?


I have an assignment to Implement telnet client and the server using TCP sockets, and execute commands such as ls, mkdir etc..

Question 1: I understand that we open socket on a specific port so that client and server can communicate using that socket. I tried this to pass the text messages, just like chat. But I would like to know if we can invoke telnet prompt and request the server to respond to client commands in this chat ?

Question 2: As understood, we can open a socket on ports > 1024 (example: 6525). But to implement Telnet protocol we use port 23. Can any one explain this implementation with a Java example.

Sorry, this may be a dumb question but im not good at networking concepts.


Solution

  • If this is a school assignment, and your assignment is to implement it using sockets, then I assume that that you are supposed to actually work with sockets, not use a third-party library that solves the problem for you (which includes using telnet.exe via the Process class).

    As telnet is a very simple, text-based protocol, this should be pretty easy using Socket, ServerSocket, and other classes in the java.net package