Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Re: Re: Re: Help with socket connections

by Clownburner (Monk)
on Nov 04, 2002 at 22:33 UTC ( [id://210315]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://210315]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-04-24 20:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found