Disabling character echo when connected to Java network

I have a Solaris daemon written in Java6. Clients can connect to it using an interface like telnet. They telnet to a specific port and I read the input lines and act on them.

At some point, I need to prompt the user for a password, and while they login, I want to disable character repetition on the telnet server.

The code has a Socket object and creates an InputStream from the result of socket getInputStream (), then reads and buffers characters from the InputStream, splitting them at cr / lf boundaries.

I don't see any attributes in either the InputStream or the Socket to turn off character repetition on the client.

Can someone nudge me in the right direction?

+1


source to share


2 answers


It looks like you need to create a simple network virtual terminal that supports no echo etc. commands. There is already a good answer on SO: Telnet Server



+4


source


You must understand where the echo comes from. TCP connections and java InputStreams do not provide echoes on their own. A telnet program executed by a user is usually run in "local echo" mode, which means that it echoes whatever the user enters on the user's screen. When a telnet client connects to an actual telnet server, it usually negotiates a "remote echo" mode, in which case the remote system provides the echo. When telnet connects to something else, like an HTTP or SMTP server, it just stays in local echo mode.

The user can issue a command to disable local echo on the client, but it would not be very convenient for your users to do this. As the other answer says, if you want to turn echo on and off, you will need to grow your server to support the telnet protocol and then negotiate the remote echo with clients.



If you do this, you will also face the problem of ruler by time and symbol by time. Telnet starts in sequence mode. It distinguishes line editing keys like backspace locally, and only sends the line to the server when the user hits back. If you are doing a remote echo, you need the echo characters as the user enters them, not after they return to return. Thus, you will have to maintain the character over time and implement line editing on the server.

You should carefully examine the telnet server program on your server. It might be possible to use an existing telnet server as an interface to your program rather than overriding everything it does. Good luck.

+2


source







All Articles