Solved

How to write a telnet server in java?

Posted on 1997-12-17
4
503 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
The viewer will learn how to implement Singleton Design Pattern in Java.

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now