mr.red has asked for the wisdom of the Perl Monks concerning the following question:

hello;
i write this code ;
but blocked by this line : "$con2->getline" ;
how to unblocking ??
#'//-------------------------------------------
use IO::Socket::INET ; use Thread ; $|++; $t = IO::Socket::INET->new( LocalAddr => "localhost", LocalPort => 90 , Listen => 1 ); $con = $t->accept(); Thread->new(\&reader_stream , $con); while(1){ $get = <STDIN> ; chomp($get); $con->autoflush(1); $con->send($get); } sub reader_stream { my $con2 = shift ; while(defined(my $recive = $con2->getline)){ print $recive."\n" ; } } close $t;
#'//-------------------
thanks

Replies are listed 'Best First'.
Re: how to unblocking with thread?
by Monkomatic (Sexton) on Feb 22, 2011 at 18:21 UTC

    Wish i could help. I'm working on threads right now and having problems myself. Linking the thread sent to thread that data that was returned when joined.

    I simply wanted to ask about $|++;

    What exactly does that do? I tried looking it up on google but no luck.

    Thanks in advance. M

      $| is a special Perl variable. $|=1; turns buffering off on the currently selected file handle. $|++; does the same thing (any non-zero value will do). In the above code, I believe that this would only apply to STDOUT.