Skip to content

Instantly share code, notes, and snippets.

@bingos
Forked from tokuhirom/poe-bug.pl
Created September 24, 2009 08:22
Show Gist options
  • Save bingos/192606 to your computer and use it in GitHub Desktop.
Save bingos/192606 to your computer and use it in GitHub Desktop.
use warnings;
use strict;
use POE;
use POE::Component::Server::TCP;
use Test::TCP;
use Test::More 0.94;
test_tcp(
client => sub {
my $port = shift;
my $sock = IO::Socket::INET->new(
PeerAddr => 'localhost',
PeerPort => $port,
) or die $!;
print $sock "hello\n";
my $res = <$sock>;
is unpack('H*', $res), unpack('H*', "hello\n");
done_testing;
},
server => sub {
my $port = shift;
POE::Component::Server::TCP->new(
Port => $port,
ClientInput => sub { $_[HEAP]->{client}->put($_[ARG0]); },
ClientFilter => [ "POE::Filter::Line", Literal => "\n" ],
);
POE::Kernel->run;
},
);
ok 1
1..1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment