Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi,

I have created a telnet server which is working fine.
now i want one more feature of Clear Screen like "cls" in DOS Prompt.

I have tried google and codeproject both but didn't find anything.

can somebody please tell, how to implement it?

Regards
AR
Posted
Updated 17-Mar-16 2:45am
Comments
Richard MacCutchan 1-Dec-11 5:24am    
Clear screen where? What is the connection with a telnet server?
Ankit Rajput 1-Dec-11 23:42pm    
sorry for delay in reply.

We have developed some services, now for interacting with these services as management console, we have created a socket listener. and now we connect it from command prompt(cmd in WinXP) with the help of Telnet command.

Now we need to give functionality of clear screen with this client.

There is one easy way. When the server gets a 'cls' (or whatever you call the command) then send 300 blank lines back. 300 is enough to deal with most buffering.

More complex solution require you to allow the user to tell your server what kind of 'terminal' type they have. Then based on that you send appropriate values back which the client maps to a clear screen. This used to work but it is unlikely to work for a windows client (you would still do the 300 blank lines). There are problems with this approach as it often seems that even though it claims it is one type of 'terminal' it doesn't behave as expected.
 
Share this answer
 
Comments
Ankit Rajput 7-Dec-11 6:55am    
thanks for replying....
But the solution of 300 lines(i have tested it) is not working in the same manner as i need it. If we restrict user to Command Prompt(Windows only), can we do something else in that case? Please suggest
telnet can only return text. So that is all that the server can do.

The client is free to do what it wants with that text. There are only two options for the client
- Blank lines.
- The client accepts special sequences of text which cause it to take action in regards to the display.

Telnet clients (not servers) often allow for an option to emulate one or more 'terminal' types. The standard windows telnet allows for the OPTION of choosing one of the following.

vt100, vt52, ansi and vtnt only

Terminal emulation is a bit iffy but clear screen is pretty common and the following link might be suitable for defining what a VT100/52 might do.


http://ascii-table.com/ansi-escape-sequences-vt-100.php[^]

Now if and ONLY if the following is true then you could allow terminal emulation in your server.
1. The telnet client must support terminal emulation
2. Terminal emulation must be turned on.
3. Terminal emulation must be set to what the server supports.
4. The terminal emulation must actually do what it claims.

If all of that is true then you could set up your server to emulate one or more terminals. However you must have a mode that doesn't emulate any terminal and you must have a way (command) that explicitly turns it on). There might be a 'standard' in which telnet clients send some info to the server automatically identifying which terminal the client expects but I am not going to reasearch that.

I will warn you that the problem with the above is that you will get users that complain that it "doesn't work". And determinig why it doesn't work can be very difficult. So if you are going to guarantee to your users that it will work versus that it might work you are going to have increased support costs.
 
Share this answer
 
So you want it in the "client".

What does that have to do with the "server"?
 
Share this answer
 
Comments
Ankit Rajput 3-Dec-11 7:03am    
I cant change client. becuase client can be command prompt or Hyperterminal.
So i need to send something from Server. Or if i can change through client then please suggest.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900