Created
September 23, 2009 22:12
-
-
Save tokuhirom/192339 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
}, | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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