X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FMsg.pm;h=615feb1987e4a102def727f208d093107f63d85b;hb=407d9a80a8af1fa6c1ae2c8fbca833e49da6e816;hp=3f52e39dfe8057d4fb202f364be81eb36567ceb3;hpb=a8dfe65f270217c237386afb696a52c1a15f5ad1;p=spider.git diff --git a/perl/Msg.pm b/perl/Msg.pm index 3f52e39d..615feb19 100644 --- a/perl/Msg.pm +++ b/perl/Msg.pm @@ -386,11 +386,29 @@ sub _rcv { # Complement to _send $bytes_read = sysread ($sock, $msg, 1024, 0); if (defined ($bytes_read)) { if ($bytes_read > 0) { - $conn->{msg} .= $msg; if (isdbg('raw')) { my $call = $conn->{call} || 'none'; dbgdump('raw', "$call read $bytes_read: ", $msg); } + if ($conn->{echo}) { + my @ch = split //, $msg; + my $out; + for (@ch) { + if (/[\cH\x7f]/) { + $out .= "\cH \cH"; + $conn->{msg} =~ s/.$//; + } else { + $out .= $_; + $conn->{msg} .= $_; + } + } + if (defined $out) { + set_event_handler ($sock, write => sub{$conn->_send(0)}); + push @{$conn->{outqueue}}, $out; + } + } else { + $conn->{msg} .= $msg; + } } } else { if (_err_will_block($!)) {