Leser: 1
5 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/perl -w
use strict;
use warnings;
use HTTP::Daemon;
use LWP::UserAgent;
our $PORT = 8018;
our $ADDRESS = '127.0.0.1';
$SIG{PIPE} = 'IGNORE';
$SIG{CHLD} = sub { wait(); };
my $srv = HTTP::Daemon->new(
LocalPort => $PORT,
LocalAddr => $ADDRESS,
Reuse => 1
);
die "Can't start server ($@)" unless defined $srv;
print "Server listening at port $PORT\n";
my $ua = LWP::UserAgent->new();
while(my $conn = $srv->accept())
{
defined(my $pid = fork()) or die "Can't fork!";
next if($pid);
while (my $request = $conn->get_request)
{
my $response = $ua->simple_request($request);
$conn->send_response($response);
}
$conn->close;
exit(0);
}
while(my $conn = $srv->accept())
5 Einträge, 1 Seite |