Solved

How to write a telnet server in java?

Posted on 1997-12-17
4
507 Views
Last Modified: 2012-08-14
I have some basis on sockets and threads.
That was enough to write an http server, but I can't understand how works the telnet protocol and/or how to receive requests.
Of course, I'm not asking for a complete implementation (telnet is much too complex!) but just for the tips that will help me to begin this server in java.
0
Comment
Question by:seguret
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
fadl earned 50 total points
ID: 1231683
Yes I agree - telnet protocol is not one of the simpliest ones.
{:)

Basically have a look at ServerSocket class in java.net.*;

ServerSocket ss=new ServerSocket(someListenPort);
while(!done){
      Socket s=ss.accept()
      //do something with s
      // now write/read something to your s
      s.close();
}
is the basic skeleton for Server
and

Socket s=new Socket(URL_of_your_server,serverPort);
DataInputStream sin=new DataInputStream( s.getInputStream());
DataOutputStream sout=new DataOutputStream(s.getOutputStream());
// now write/read something to your socket

and that's all....
PS: Check the javadoc documentation for exact parameters/method
names.

HTH
Michal
0
 
LVL 4

Expert Comment

by:rembo
ID: 1231684
0
 
LVL 4

Author Comment

by:seguret
ID: 1231685
Ok,
thanx for the answer, but my problem was elsewhere (of course I knew how to open a serverSocket).
I found my problem :
I didn't think at first that a telnet client can connect without sending any text. It was why I was seeing nothing....
I just had to type something in my client interface !

0
 
LVL 1

Expert Comment

by:fadl
ID: 1231686
I see...
Your question was not quite clear I think.

Happy Javing
Michal
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Unhandled exception type Exception 18 52
Convert from a json string array to a Java object 3 65
Eclipse Java import and method not resolved 4 82
glassfish admin console 1 23
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question