【Perl】初心者コーナー Part18
■ このスレッドは過去ログ倉庫に格納されています
0883864 2/3
03/01/07 01:49ID:???----httpd.plとして作成
use HTTP::Daemon;
use HTTP::Status;
my $d = new HTTP::Daemon(LocalPort =>$ARGV[0]) || die;
print "Please contact me at: <URL:", $d->url, ">\n";
while (my $c = $d->accept) {
my ($family, $port, $heraddr) =unpack('S n a4 x8',$c->peername);
while (my $r = $c->get_request) {
print "Accept from:".Socket::inet_ntoa($heraddr)." Port:".$port."\n";
print " User-Agent:".$$r{"_headers"}{"user-agent"}."\n";
if ($r->method eq 'GET' and (-e '.'.$r->url->path)) {
if ($c->send_file_response('.'.$r->url->path)) {
print "Get file: .".$r->url->path."\n" ;
}
} else {
print "Not Respons ".$r->method." ".$r->url->path."\n" ;
$c->send_error(RC_FORBIDDEN)
}
}
print "Close Connection :".Socket::inet_ntoa($heraddr)."\n";
$c->close;
undef($c);
}
----
■ このスレッドは過去ログ倉庫に格納されています