delete $conn->{cmd};
$conn->{timeout}->del if $conn->{timeout};
delete $conn->{timeout};
- $conn->_send_file("$main::data/connected");
&{$conn->{rproc}}($conn, "$dir$call|$sort");
+ $conn->_send_file("$main::data/connected");
}
sub new_client {
my $server_conn = shift;
my $sock = $server_conn->{sock}->accept();
- my $conn = $server_conn->new($server_conn->{rproc});
- $conn->{sock} = $sock;
-
- my ($rproc, $eproc) = &{$server_conn->{rproc}} ($conn, $conn->{peerhost} = $sock->peerhost(), $conn->{peerport} = $sock->peerport());
- if ($eproc) {
- $conn->{eproc} = $eproc;
- Msg::set_event_handler ($sock, "error" => $eproc);
+ if ($sock) {
+ my $conn = $server_conn->new($server_conn->{rproc});
+ $conn->{sock} = $sock;
+ Msg::blocking($sock, 0);
+ $conn->{blocking} = 0;
+
+ my ($rproc, $eproc) = &{$server_conn->{rproc}} ($conn, $conn->{peerhost} = $sock->peerhost(), $conn->{peerport} = $sock->peerport());
+ if ($eproc) {
+ $conn->{eproc} = $eproc;
+ Msg::set_event_handler ($sock, "error" => $eproc);
+ }
+ if ($rproc) {
+ $conn->{rproc} = $rproc;
+ my $callback = sub {$conn->_rcv};
+ Msg::set_event_handler ($sock, "read" => $callback);
+ # send login prompt
+ $conn->{state} = 'WL';
+ # $conn->send_raw("\xff\xfe\x01\xff\xfc\x01\ff\fd\x22");
+ # $conn->send_raw("\xff\xfa\x22\x01\x01\xff\xf0");
+ # $conn->send_raw("\xFF\xFC\x01");
+ $conn->_send_file("$main::data/issue");
+ $conn->send_raw("login: ");
+ $conn->_dotimeout(60);
+ } else {
+ &{$conn->{eproc}}() if $conn->{eproc};
+ $conn->disconnect();
+ }
+ } else {
+ dbg('err', "ExtMsg: error on accept ($!)");
}
- if ($rproc) {
- $conn->{rproc} = $rproc;
- my $callback = sub {$conn->_rcv};
- Msg::set_event_handler ($sock, "read" => $callback);
- # send login prompt
- $conn->{state} = 'WL';
-# $conn->send_raw("\xff\xfe\x01\xff\xfc\x01\ff\fd\x22");
-# $conn->send_raw("\xff\xfa\x22\x01\x01\xff\xf0");
-# $conn->send_raw("\xFF\xFC\x01");
- $conn->_send_file("$main::data/issue");
- $conn->send_raw("login: ");
- $conn->_dotimeout(60);
- } else {
- $conn->disconnect();
- }
}
sub start_connect
*STDOUT = IO::File->new_from_fd($b, 'w') or die;
*STDERR = IO::File->new_from_fd($b, 'w') or die;
close $a;
- unless ($^O =~ /^MS/) {
+ unless ($main::is_win) {
# $SIG{HUP} = 'IGNORE';
$SIG{HUP} = $SIG{CHLD} = $SIG{TERM} = $SIG{INT} = 'DEFAULT';
alarm(0);
return;
}
if ($line =~ /\Q$expect/i) {
- dbg('connect', "got: \"$expect\" sending: \"$send\"");
- $conn->send_later("D$conn->{call}|$send");
+ if (length $send) {
+ dbg('connect', "got: \"$expect\" sending: \"$send\"");
+ $conn->send_later("D$conn->{call}|$send");
+ }
delete $conn->{msg}; # get rid any input if a match
return;
}
if ($f) {
while (<$f>) {
chomp;
+ dbg('connll', $_);
$conn->send_raw($_ . $conn->{lineend});
}
$f->close;