my $conn = shift;
my $msg;
- while ($msg = shift @{$conn->{inqueue}}){
+ while (@{$conn->{inqueue}}){
+ $msg = shift @{$conn->{inqueue}};
dbg('connect', $msg) unless $conn->{state} eq 'C';
$msg =~ s/\xff\xfa.*\xff\xf0|\xff[\xf0-\xfe].//g; # remove telnet options
}
}
if ($conn->{msg} && $conn->{state} eq 'WC' && exists $conn->{cmd} && @{$conn->{cmd}}) {
+ dbg('connect', $conn->{msg});
$conn->_docmd($conn->{msg});
if ($conn->{state} eq 'WC' && exists $conn->{cmd} && @{$conn->{cmd}} == 0) {
$conn->{state} = 'C';
if ($f) {
while (<$f>) {
chomp;
- $conn->send_later($_);
+ $conn->send_raw($_ . $conn->{lineend});
}
$f->close;
}
if ($bytes_read > 0) {
if ($msg =~ /\n/) {
@lines = split /\r?\n/, $msg;
- $lines[0] = '' unless @lines;
- $lines[0] = $conn->{msg} . $lines[0] if exists $conn->{msg};
- push @lines, ' ' unless @lines;
+ if (@lines) {
+ $lines[0] = $conn->{msg} . $lines[0] if exists $conn->{msg};
+ } else {
+ $lines[0] = $conn->{msg} if exists $conn->{msg};
+ push @lines, '' unless @lines;
+ }
if ($msg =~ /\n$/) {
delete $conn->{msg};
} else {