Skip to content

Instantly share code, notes, and snippets.

@tokuhirom
Created September 23, 2009 22:12
Show Gist options
  • Save tokuhirom/192339 to your computer and use it in GitHub Desktop.
Save tokuhirom/192339 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]); },
);
POE::Kernel->run;
},
);
not ok 1
# Failed test at /home/tokuhirom/share/cpan/lib/perl5/Test/Builder.pm line 1069.
# got: '68656c6c6f0d0a'
# expected: '68656c6c6f0a'
1..1
# Looks like you failed 1 test of 1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment