Thanks for all reactions. The server does not
generate error-messages, but this version uses
more memory with each call.
Any idea why? Any idea how to fix it?
#!/usr/bin/perl
use strict;
use threads;
use threads::shared;
use IO::Socket;
use IO::Select;
my ($thr,$tid);
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 ((!($tid = threads->tid()))&&(my $client = $socket->accept)) {
$thr = threads->create(\&process_request,$client);
$tid = threads->tid();
print "main: $tid\n";
$thr->detach;
}
print "done: exit\m";
##
## process the request
##
sub process_request {
my $socket = $_[0];
local %ENV = ();
$thrcnt++;
#
#do my thing
#
my $ltid = threads->tid();
print "loop: $thrcnt, $ltid\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