X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2Fclient.pl;h=9f39fdd135c42e22cc1a2249528e06edfaf6fdb4;hb=638d9efe6fe3d3c4eec08d5e985fce4dd760423b;hp=2e6a4f1727452652d1b32f3ccf7353e2016cedd9;hpb=e0278322b79d09a997ed7df948c57b58f02b139c;p=spider.git diff --git a/perl/client.pl b/perl/client.pl index 2e6a4f17..9f39fdd1 100755 --- a/perl/client.pl +++ b/perl/client.pl @@ -41,10 +41,10 @@ BEGIN { use Msg; use DXVars; use DXDebug; +use Net::Telnet qw(TELOPT_ECHO); use IO::File; use IO::Socket; use IPC::Open2; -use Net::Telnet qw(TELOPT_ECHO); use Carp qw{cluck}; # cease communications @@ -53,6 +53,7 @@ sub cease my $sendz = shift; if ($conn && $sendz) { $conn->send_now("Z$call|bye...\n"); + sleep(1); } $stdout->flush if $stdout; if ($pid) { @@ -62,6 +63,9 @@ sub cease dbgclose(); # $SIG{__WARN__} = sub {my $a = shift; cluck($a); }; sleep(1); + + # do we need this ? + $conn->disconnect if $conn; exit(0); } @@ -209,12 +213,13 @@ sub doconnect $port = 23 if !$port; # if ($port == 23) { + $sock = new Net::Telnet (Timeout => $timeout, Port => $port); $sock->option_callback(\&optioncb); $sock->output_record_separator(''); - $sock->option_log('option_log'); - $sock->dump_log('dump'); - $sock->option_accept(Wont => TELOPT_ECHO); +# $sock->option_log('option_log'); +# $sock->dump_log('dump'); + $sock->option_accept(Dont => TELOPT_ECHO, Wont => TELOPT_ECHO); $sock->open($host) or die "Can't connect to $host port $port $!"; # } else { # $sock = IO::Socket::INET->new(PeerAddr => "$host:$port", Proto => 'tcp') @@ -269,6 +274,10 @@ sub dochat $line = <$rfh>; $line =~ s/\r//og; } + if (length $line == 0) { + dbg('connect', "received 0 length line, aborting..."); + cease(11); + } dbg('connect', "received \"$line\""); if ($abort && $line =~ /$abort/i) { dbg('connect', "aborted on /$abort/"); @@ -492,7 +501,7 @@ Msg->set_event_handler($stdin, "read" => \&rec_stdin); for (;;) { my $t; - Msg->event_loop(1, 0.010); + Msg->event_loop(1, 1); $t = time; if ($t > $lasttime) { if ($outqueue) {