package ProtoConnection;

use strict;
use warnings;

# Load the Apache modules that allow us to access the Apache API
use Apache2::Connection ();
use APR::Const -compile => qw(:common :poll);
use APR::Socket         ();


sub handler {
    my ( $c ) = @_;

    my $sock = $c->client_socket();

    # set up some values before we enter our read loop
    my $want = 1024;
    my $buff = '';
    my $len = $sock->recv($buff, $want);

    warn "got the message\n";
    sleep 10;
    warn "sending the response\n";

    my $wlen = eval { $sock->send( "I heard $buff\n" ) };
    if ($@) {
        warn "They hung up!\n";
    }
    else {
        warn "sent $wlen bytes\n";
        $sock->close();
    }

    # We're all done.
    return 0;
}

1;



