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

IIRC recv doesn't block. Try setting up a test case using something like sysread, which should block, or fail when the socket closes. It will either work, or it will show you that the networking library is truely stuffed. You may be out of luck if the network library is stuffed, since perl tends to call straight through to the system, which means your system libraries are giving you trouble.

You could probably write your routine using sysread and having it time out in .1 second, which would preserve interactivity.

____________________
Jeremy
I didn't believe in evil until I dated it.

  • Comment on Re: Re: Re: Help with socket connections

Replies are listed 'Best First'.
Re: Re: Re: Re: Help with socket connections
by Clownburner (Monk) on Nov 04, 2002 at 22:33 UTC
    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