Solved

How to write a telnet server in java?

Posted on 1997-12-17
4
501 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
Comment Utility
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
Comment Utility
0
 
LVL 4

Author Comment

by:seguret
Comment Utility
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
Comment Utility
I see...
Your question was not quite clear I think.

Happy Javing
Michal
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This video teaches viewers about errors in exception handling.

763 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

11 Experts available now in Live!

Get 1:1 Help Now