There's a couple of things wrong here. The main one being that you're not actually starting the kernel (admittedly PoCo::Server::HTTPD's docs are lacking a bit in this respect). What you need to do is create a session and then start the kernel:
POE::Session->create(
inline_states => {
_start => \&create_httpd,
_stop => \&stop_httpd,
},
args => [8080],
);
$poe_kernel->run;
sub create_httpd {
my ($kernel, $heap, $Port) = @_[KERNEL, HEAP, ARG0];
$kernel->alias_set('httpd_parent');
my $httpd = POE::Component::Server::HTTP->new
(
Port => $Port,
ContentHandler => { '/' => \&MainHandler },
Headers => {Server => 'any server' },
);
$heap->{httpd} = $httpd;
}
sub stop_httpd {
my ($kernel, $heap) = @_[KERNEL, HEAP];
$kernel->call($heap->{httpd}, 'shutdown');
}
sub MainHandler {
my ($request, $response) = @_;
$response->code(RC_OK);
$response->content("Hi, you fetched ". $request->uri);
return RC_OK;
} # MainHandler
The other thing wrong is a bug in PoCo::Server::HTTP - it uses the deprecated _signal event, but luckily for you it simply sets it to an empty sub, so you can comment that line out (just grep for _signal in the HTTP.pm file in the distro).
(Note: I haven't tested the above code, so it might not work. But it should).
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.