I'm reading data from a socket as shown below. My goal is whenever data is ready to be read from $sock, it's passed to the sub routine "processIn". Depending on the data, it could take 30 seconds or more for processIn to finish, but I don't want that to block subsequent requests.
The code below isn't working as I expect it to. If processIn is called and takes 30 seconds to finish, data that arrived in between isn't processed until after processIn is done. Does anyone know why?
...
while (<$sock>) {
$text = $_;
chomp($text);
my $processInTHR = threads->new(\&processIn($text));
$processInTHR->detach;
}
The code below isn't working as I expect it to. If processIn is called and takes 30 seconds to finish, data that arrived in between isn't processed until after processIn is done. Does anyone know why?
...
while (<$sock>) {
$text = $_;
chomp($text);
my $processInTHR = threads->new(\&processIn($text));
$processInTHR->detach;
}