如何用TIdTelnet抑制回声? [英] How to supress echo with TIdTelnet?
问题描述
使用Indy10-DelphiXE。
如何使用 TIdTelnet
告诉正在连接的telnet服务器不回显我发送给telnet服务器的命令?
这是我当前的尝试(不起作用),我尝试在每次telnet写入时发送序列IAC DO SUPPRESS_LOCAL_ECHO,但是我确实认为这必须在协商阶段完成?
使用
TIdTelnet,
...
过程TIOTelnetConnection.SendSupressEcho;
var
响应:TIdBytes;
开始
SetLength(Resp,3);
Resp [0]:= TNC_IAC;
Resp [1]:= TNC_DO;
Resp [2]:= TNO_SUPLOCALECHO;
FIOConnection.IOHandler.Write(Resp);
结尾;
过程TIOTelnetConnection.Write(Str:AnsiString);
开始
SendSupressEcho;如果Str<>为
’然后
FIOConnection.IOHandler.Write(Str);
结尾;
看着 TIdTelnet
源,我看到了协商
过程,但是受到保护,如何覆盖它的行为?
如果服务器向您发送 IAC WILL ECHO
,则 TIdTelnet
会硬编码为发送 IAC DO ECHO
响应,然后触发 OnTelnetCommand(tncNoLocalEcho)
事件,告诉您不要在本地回显您发送的内容。 / p>
如果服务器向您发送 IAC WONT ECHO
,则 TIdTelnet
被硬编码为发送 IAC DONT ECHO
响应,然后触发 OnTelnetCommand(tncLocalEcho)
事件
如果服务器向您发送 IAC DO ECHO
,则 TIdTelnet
被硬编码为发送 IAC WILL ECHO
响应,然后触发 OnTelnetCommand(tncEcho )
事件告诉您回显
如果服务器向您发送 IAC DONT ECHO
,则 TIdTelnet
被硬编码为发送 IAC WONT ECHO
响应,然后触发 OnTelnetCommand(tncLocalEcho)
事件,告诉您回显收到的任何内容。
因此,如果您不希望服务器回显您,则可以发送 IAC DONT ECHO
命令发送到服务器,而不是 IAC DO SUPLOCALECHO
命令。然后,服务器将相应地返回 IAC WONT ECHO
或 IAC WILL ECHO
(显然是 TIdTelnet
随后将进行答复,但服务器将不会再次响应,因为其 ECHO
当前状态不会更改,从而避免了无休止的响应循环)。
Using Indy10 - DelphiXE.
How do I tell the telnet server I am connecting to with TIdTelnet
to not echo the commands I send towards the telnet server?
This is my current attempt (which doesn't work), I try to send the sequence IAC DO SUPPRESS_LOCAL_ECHO on each telnet write but I do believe this has to be done in the negotiating phase?
uses
TIdTelnet,
...
procedure TIOTelnetConnection.SendSupressEcho;
var
Resp: TIdBytes;
begin
SetLength(Resp, 3);
Resp[0] := TNC_IAC;
Resp[1] := TNC_DO;
Resp[2] := TNO_SUPLOCALECHO;
FIOConnection.IOHandler.Write(Resp);
end;
procedure TIOTelnetConnection.Write(Str: AnsiString);
begin
SendSupressEcho;
if Str <> '' then
FIOConnection.IOHandler.Write(Str);
end;
looking at the TIdTelnet
source I see the Negotiate
procedure, but it is protected, how can I override it's behaviour?
If the server sends an IAC WILL ECHO
to you, TIdTelnet
is hard-coded to send an IAC DO ECHO
response, and then triggers an OnTelnetCommand(tncNoLocalEcho)
event to tell you not to locally echo what you send.
If the server sends an IAC WONT ECHO
to you, TIdTelnet
is hard-coded to send an IAC DONT ECHO
response, and then triggers an OnTelnetCommand(tncLocalEcho)
event to tell you to locally echo what you send.
If the server sends an IAC DO ECHO
to you, TIdTelnet
is hard-coded to send an IAC WILL ECHO
response, and then triggers an OnTelnetCommand(tncEcho)
event to tell you to echo back whatever you receive.
If the server sends an IAC DONT ECHO
to you, TIdTelnet
is hard-coded to send an IAC WONT ECHO
response, and then triggers an OnTelnetCommand(tncLocalEcho)
event to tell you to echo back whatever you receive.
So, if you don't want the server to echo back to you, you can send an IAC DONT ECHO
command to the server, not an IAC DO SUPLOCALECHO
command. The server will then reply with either IAC WONT ECHO
or IAC WILL ECHO
accordingly (which apparently TIdTelnet
will then reply to, but the server will not respond back again since its ECHO
current state does not change, avoiding an endless response loop).
这篇关于如何用TIdTelnet抑制回声?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!