Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

threads

Status
Not open for further replies.

plunkett

Technical User
Joined
Jun 10, 2004
Messages
57
Location
US
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;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top