1 package AnyEvent
::HTTPD
::HTTPServer
;
10 use AnyEvent
::HTTPD
::HTTPConnection
;
12 our @ISA = qw
/Object::Event/;
16 AnyEvent::HTTPD::HTTPServer - A simple and plain http server
20 This class handles incoming TCP connections for HTTP clients.
21 It's used by L<AnyEvent::HTTPD> to do it's job.
23 It has no public interface yet.
25 =head1 COPYRIGHT & LICENSE
27 Copyright 2008 Robin Redeker, all rights reserved.
29 This program is free software; you can redistribute it and/or modify it
30 under the same terms as Perl itself.
36 my $class = ref($this) || $this;
42 IO
::Socket
::INET
->new (
44 LocalPort
=> $self->{port
},
49 $sock or die "Couldn't create listening socket: $!";
51 tcp_server
undef, $self->{port
}, sub {
54 $self->event (error
=> "couldn't accept client: $!");
57 $self->accept_connection ($fh);
63 sub accept_connection
{
66 my $htc = AnyEvent
::HTTPD
::HTTPConnection
->new (fh
=> $fh);
67 $self->{handles
}->{$htc} = $htc;
69 $htc->reg_cb (disconnect
=> sub {
70 delete $self->{handles
}->{$_[0]};
71 $self->event (disconnect
=> $_[0])
74 $self->event (connect => $htc);