Solved

How to write a telnet server in java?

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JList custom Cell Renderer refresh 15 57
what is a "java.lang.System Property"   ? 20 67
varialbe initialization 11 33
Windows 10 IE Certificate Issue 10 45
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
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 …

809 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