-
-
Save bingos/192606 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]); }, | |
ClientFilter => [ "POE::Filter::Line", Literal => "\n" ], | |
); | |
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
ok 1 | |
1..1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment