#!/usr/bin/perl use bytes; use HTTP::Daemon; use HTTP::Status; $SIG{PIPE} = 'IGNORE'; my $res = HTTP::Response->new(RC_OK); $res->content("Hello World\n"); $res->content_type('text/plain'); $|++; my $d = HTTP::Daemon->new( LocalPort => 9876, ReuseAddr => 1 ) || die; print "Please contact me at: url, ">\n"; for ( 1 .. 20 ) { my $pid = fork; next if $pid; next unless defined $pid; do { flock $d, 2; my $c = $d->accept; flock $d, 8; my $oldfh = select($c); $|++; select($oldfh); while ( my $r = $c->get_request ) { if ( $r->method eq 'GET' ) { #and $r->url->path eq "/hello" ) { $c->send_response($res); } else { $c->send_error(RC_FORBIDDEN); } } $c->close; undef($c); } while (1); exit 0; } while (1) { waitpid( -1, 0 ) }