my $conn = {
rproc => $rproc,
inqueue => [],
+ outqueue => [],
state => 0,
lineend => "\r\n",
csort => 'telnet',
my ($conn, $flush) = @_;
my $sock = $conn->{sock};
return unless defined($sock);
- my ($rq) = $conn->{outqueue};
+ my $rq = $conn->{outqueue};
# If $flush is set, set the socket to blocking, and send all
# messages in the queue - return only if there's an error
if ($bytes_read > 0) {
if ($msg =~ /\n/) {
@lines = split /\r?\n/, $msg;
- $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 {