Solved

How to write a telnet server in java?

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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
map related example 6 55
eclipse buid path vs tomcat lib path 10 34
String array comparison 4 38
ejb mdb examples 1 8
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

837 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