#!/usr/bin/perl -w # # simple client # use warnings; use strict; use POE; use POE::Component::Client::TCP; use POE::Filter::Stream; my $host = "localhost"; my $port = 38888; POE::Component::Client::TCP->new( RemoteAddress => $host, RemotePort => $port, Filter => "POE::Filter::Stream", Connected => sub { print "connected to $host:$port ...\n"; #now send 10 commands in a row. # is this the right way to send a sequence? foreach my $i(1..10){ $_[HEAP]->{server}->put("command-$i"); } }, ConnectError => sub { print "could not connect to $host:$port ...\n"; }, ServerInput => sub { my ( $kernel, $heap, $input ) = @_[ KERNEL,HEAP, ARG0 ]; print "$input\n"; }, ); POE::Kernel->run(); exit 0;