in reply to Re: Re: Re: Help with socket connections
in thread Help with socket connections

Fixed it! With some help from a nice guy on another forum, but this was the solution: The recv call was getting stuck in a loop when the telnet session died unexpectedly - this might be a perl bug. The solution involved IO::Select, which works like a champ:
# this is the fork's parent, the master's child if ($kidpid) { set_state("$rs_info <-- $lc_info"); my $buf = ""; select($remote_server); $| = 1; my $s=IO::Select->new(); $s->add($local_client); while (my @ready=$s->can_read()) { my $r=recv($local_client,$buf,1,0); warn "local recv - $!" unless(defined($r)); last unless(length($buf)); print $buf; }; print STDOUT "Child Exiting: $lc_info --> $rs_info\n" if $de +bug; log_info(0,$user,$lc_info,$rs_info); # Log disconnect kill('TERM', $kidpid); # kill my twin cause we're done } # this is the fork's child, the master's grandchild else { set_state("$rs_info --> $lc_info"); my $buf = ""; select($local_client); $| = 1; my $s=IO::Select->new(); $s->add($remote_server); while (my @ready=$s->can_read()) { my $r=recv($remote_server,$buf,1,0); warn "remote recv - $!" unless(defined($r)); last unless(length($buf)); print $buf; }; print STDOUT "Grandchild Exiting: $lc_info <-- $rs_info\n" i +f $debug; kill('TERM', getppid()); # kill my twin cause we're done }
Thanks everyone, for your help on this.
"Non sequitur. Your facts are un-coordinated." - Nomad