This program is a very simple client/server script. It sends a array over a TCP connection and return the sum of it.

The main purpose is to show how the POE::Filter::Reference works.

This is the Server script:

use strict;

# use both POE server and the filter needed
use POE qw(Component::Server::TCP Filter::Reference);
  Alias        => "sum_server",
  Port         => 11211,
  ClientFilter => "POE::Filter::Reference",
  ClientInput  => sub {
    my ($sender, $heap, $input) = @_[SESSION, HEAP, ARG0];
    my $result = $input->[0] + $input->[1];
exit 0;

And this is the client script:

#!/usr/bin/perl -w
use strict;
use POE;
use POE::Component::Client::TCP;
use POE::Filter::Reference;
my $host   = "localhost";    # The host to test.
my $port   = 11211;
my @values = (2, 3);
  RemoteAddress => $host,
  RemotePort    => $port,
  Filter        => "POE::Filter::Reference",
  Connected     => sub {
    my $j = "teste";
    print "connected to $host:$port ...\n";
  ConnectError => sub {
    print "could not connect to $host:$port ...\n";
  ServerInput => sub {

    #when the server answer the question
    my ($kernel, $heap, $input) = @_[KERNEL, HEAP, ARG0];
    print "got result from $host:$port ... YAY!\n";

    #print to screen the result
    print $$input. "\n";
exit 0;

And that's it.