Hi,
I'm one step further. There seems to be a bug/problem in detach,
found by Dave.
At the moment the script runs fine on Linux and Windows, tested
with a few hundred connects, but I'm told that this script crashes
after three connects when packed with PDK (perlapp).
Any idea?
#!/usr/bin/perl
use strict;
use threads;
use threads::shared;
use IO::Socket;
my $thrcnt : shared = 0;
my $port = 1080;
my $socket = IO::Socket::INET->new( LocalPort => $port,
Type => SOCK_STREAM,
Listen => SOMAXCONN,
ReuseAddr => 1
) or die "Can't create listen socket: $!";
while ((!(my $tid = threads->tid()))&&(my $client = $socket->accept)) {
my $thr = threads->create(\&process_request,$client);
$thr->detach;
$tid = threads->tid();
}
print "done\n";
##
## process the request
##
sub process_request {
my $socket = $_[0];
my ($tid);
local %ENV = ();
$thrcnt++;
#
#
#do my thing
$tid = threads->tid();
print "counter: $thrcnt, $tid\n";
#
#
close $socket;
}
--
_______________________________________________
Surf the Web in a faster, safer and easier way:
Download Opera 8 at http://www.opera.com
Powered by Outblaze
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs