============================ use 5.008; # 5.8 required for stable threading use strict; use warnings; use threads; # threading routines use threads::shared; # and variable sharing routines use HTTP::Daemon; my $daemon = HTTP::Daemon->new( LocalPort => 3126, Listen => 5, Reuse => 1 ); die "Cannot listen\n" unless defined $daemon; $daemon->autoflush(1); my $client; while( 1 ) { $client = $daemon->accept; print STDERR "got connect\n"; threads->create("start_thread", $client ); # threads->new(\&start_thread, $client ); } $daemon->shutdown(2); exit; sub start_thread { threads->self->detach(); print STDERR "Thread started\n"; print STDERR $_[0] . "\n"; my $client= $_[0]; my $request = $client->get_request; print STDERR "====Got request=Start=====\n"; print STDERR $request->as_string; return; } ========================= output: ----------------------- got connect Thread started HTTP::Daemon::ClientConn=GLOB(0x1f2d640) got connect Thread started HTTP::Daemon::ClientConn=GLOB(0x20e8e08) got connect ====Got request=Start===== GET http://www.google.com/ HTTP/1.0 Accept: image/gif, image/jpeg, */* Accept-Language: en Host: www.google.com User-Agent: Mozilla/4.7 (compatible; OffByOne; Windows 2000) Webster Pro V3.2 ====Got request=Start===== GET http://www.yahoo.com/ HTTP/1.0 Accept: image/gif, image/jpeg, */* Accept-Language: en Host: www.yahoo.com User-Agent: Mozilla/4.7 (compatible; OffByOne; Windows 2000) Webster Pro V3.2 Thread started HTTP::Daemon::ClientConn=GLOB(0x33135d8) ----------------------------------------