For Programmers: Free Programming Magazines  


Home > Archive > Tcl > June 2005 > using interact with TCP socket









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author using interact with TCP socket
Phil Freed

2005-05-26, 9:01 pm

Platform: WinXP, cygwin

I have wrote a simple converter in Expect that is designed to take in a
telnet connection and pass it through to an SSH connection.

basically, the code is simple:

socket -server Server -myaddr 127.0.0.1 5555
vwait forever

And the Server routine (simplified to remove error checks and the like) is:

proc Server {channel clientAddr clientPort} {
spawn -open $channel
set telnet $spawn_id

spawn "/usr/bin/ssh" user@domain.com
interact -u $telnet
}

This works fine, except that anything typed into my telnet session appears
on the screen twice. I've tried everything I can think of -- changing the
spawns to noecho, nottyinit & nottycopy, etc. Is this an artifact of
opening a TCP connection with "spawn -open"? Is there something simple that
I'm missing? Is it simply the platform that I'm on?

Thanks for any light you may be able to shed on this.


Don Libes

2005-05-31, 8:59 pm

"Phil Freed" <clt505@freed.com> writes:

> Platform: WinXP, cygwin
>
> I have wrote a simple converter in Expect that is designed to take in a
> telnet connection and pass it through to an SSH connection.
>
> basically, the code is simple:
>
> socket -server Server -myaddr 127.0.0.1 5555
> vwait forever
>
> And the Server routine (simplified to remove error checks and the like) is:
>
> proc Server {channel clientAddr clientPort} {
> spawn -open $channel
> set telnet $spawn_id
>
> spawn "/usr/bin/ssh" user@domain.com
> interact -u $telnet
> }
>
> This works fine, except that anything typed into my telnet session appears
> on the screen twice. I've tried everything I can think of -- changing the
> spawns to noecho, nottyinit & nottycopy, etc. Is this an artifact of
> opening a TCP connection with "spawn -open"? Is there something simple that
> I'm missing? Is it simply the platform that I'm on?
>
> Thanks for any light you may be able to shed on this.


If I understand your scenario (very cute by the way!), the extra echo
is being generated by your telnet client itself. You didn't show you
are using a telnet client in the scenario but I assume that's what
you're using, yes? The telnet client has a property of echoing by
default if used to any non-telnetd port.

Off the top of my head, I forget the option to turn off echoing, but
you can find it in any telnet documentation. However, telnet also
uses a very crude line mode (which is why echoing is kinda important).
Depending on your requirements, you might want to deal with that too.

Don
Michael A. Cleverly

2005-06-08, 4:01 pm

On Tue, 31 May 2005, Don Libes wrote:

> "Phil Freed" <clt505@freed.com> writes:


[color=darkred]
> Off the top of my head, I forget the option to turn off echoing, but
> you can find it in any telnet documentation. However, telnet also
> uses a very crude line mode (which is why echoing is kinda important).
> Depending on your requirements, you might want to deal with that too.


The OP could try doing a:

puts [format %c%c%c 255 251 1]

to output the escape code to tell (a proper) telnet client to turn off
echo. For reference, you could (request to) turn it back on with:

puts [format %c%c%c 255 252 1]

Michael
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com