serving lanterna to a telnet client

394 views
Skip to first unread message

msx

unread,
Aug 22, 2012, 7:50:53 AM8/22/12
to lanterna...@googlegroups.com
Hello, i just looked around how lanterna works and i like it.
What i want to do is the following: users connects to my server with a telnet client (windows telnet, putty or whatever), i manage connections, and i want to serve them my lanterna GUI.
How is it possible? using the various UnixTerminal, SwingTerminal and CygwinTerminal all opens new graphical windows. I don't want to open any window, the gui should appear to the remote telnet machines.

I managed to do this: i disabled graphics with -Djava.awt.headless=false and passed my client's socket Input and Output streams to TerminalFacade to create a terminal connected to the socket, like this:

Socket clientSocket = serverSocket.accept();
Terminal rawTerminal =  TerminalFacade.createTerminal(clientSocket.getInputStream(), clientSocket.getOutputStream(),Charset.forName("UTF8"));
       
this somehow work but using any telnet client i get a lot of garbage on the screen, and some code that appears written on the screen every second ([[24;80R)

What is the correct way of doing this? Where am i wrong?

Thanks :)

Shannon Haworth

unread,
Aug 22, 2012, 9:17:52 AM8/22/12
to lanterna...@googlegroups.com
What you are seeing are the raw ANSI/VT100 terminal codes.  Normally when a terminal session is established the operating system initializes the remote terminal.  However, by connecting to the java app directly, you are bypassing terminal initialization.  The result are the raw terminal codes.

Your choices seem to be:

1) Initialize the terminal yourself (and likely reveal the next set of problems).
2) Don't re-invent the wheel and allow a UNIX / Linux instance to process the incoming connecting / launch the java application.  A half-decent unix sysadmin will be able to configure xinetd to do exactly what you need.  However, the details are well outside of the scope of this mailing list should you decide to go that route.

Shannon

Martin

unread,
Aug 26, 2012, 9:11:35 AM8/26/12
to lanterna...@googlegroups.com
As Shannon pointed out, what you are seeing are the ANSI/VT100 terminal codes. I'm not quite sure of the details of initializing the terminal, I would think you are on the right track by creating a terminal using the sockets input and output streams instead of System.in and System.out, but I'm not sure what's missing. Possibly, there is more to telnet than just sending stdin and stdout or the wire? I suspect reading up on the telnet standard could be a good start.
If you do get some progress on this though, please feel free to share it with us here!

Thank you,
Martin

Justin Smith

unread,
Mar 22, 2013, 8:47:55 PM3/22/13
to lanterna...@googlegroups.com
This post was a while ago, but for others looking... I was able to get this working in HyperTerminal, which conveniently no longer ships with newer copies of Windows.  I did have to explicitly set the emulation to VT100.

Martin Berglund

unread,
Mar 26, 2013, 7:55:33 AM3/26/13
to lanterna...@googlegroups.com
Yeah, this is such an obvious feature that should be part of the library and better tested... 

...one of these days...

Martin

2013/3/23 Justin Smith <mag...@gmail.com>
--
Det här meddelandet skickas till dig eftersom du prenumererar på gruppen lanterna-discuss i Google Groups.
Om du vill sluta prenumerera på den här gruppen och inte längre få någon e-post från den skickar du ett e-postmeddelande till lanterna-discu...@googlegroups.com.
Fler alternativ finns på https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages