I'm obviously new at this POE thing. I'm trying to understand
performance parameters for POE and cobbled the code below mosty by
cutting and pasting from the manual pages.  The server below driven
by the client further below hangs when it consumes all the available
socket buffers.  What have I screwed up?

    #!/usr/bin/perl

    use POE;
    use POE::Component::Server::TCP;
    use IO::Socket;
    use Time::HiRes qw( time );
    use strict;
    use warnings;

    sub accept_handler {
        my ($socket, $remote_address, $remote_port) = @_[ARG0, ARG1, ARG2];
        my $ip = inet_ntoa($remote_address);
        print "got connect from $ip:$remote_port\n";

        print $socket time(), "\n";
        $socket->close();
    }

    sub error_handler {
        my ($op, $errnum, $errstr) = @_[ARG0, ARG1, ARG2];
        warn "server encountered $op error $errnum: $errstr";
        # possibly shut down the server
    }

    POE::Component::Server::TCP->new
    (
        Port     => '8080',
        Acceptor => \&accept_handler,
        Error    => \&error_handler,  # Optional.
    );

    $poe_kernel->run();
    exit 0;

    #!/usr/bin/perl

    use IO::Socket;
    use Time::HiRes qw( time sleep );
    use strict;
    use warnings;

    my $n;
    my $c;
    my $s;

    while (1) {
        $s = time();
        $n = IO::Socket::INET->new(
            PeerPort => 8080,
            PeerAddr => 'localhost',
        ) or die "$0: can't connect";

        print time(), " ", (time() - $s)," ", $c++, "\n";
        $n->close();
    }

__END__
--
    Chris Fedde

Reply via email to