Created
February 9, 2015 13:11
-
-
Save creaktive/a0e0a5db848bccab4314 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
#!/usr/bin/env perl | |
use strict; | |
use warnings qw(all); | |
use IO::Socket; | |
use IPC::Run qw(harness pump); | |
my @command = ('cat'); | |
my ($in, $out, $err); | |
my $h = harness \@command, \$in, \$out, \$err; | |
start $h; | |
my $srv = IO::Socket::INET->new( | |
Proto => 'tcp', | |
LocalAddr => '127.0.0.1', | |
LocalPort => 12345, | |
Listen => SOMAXCONN, | |
Reuse => 1, | |
) || die "oops: $!"; | |
while (my $cli = $srv->accept()) { | |
my $text = <$cli>; | |
$in = $text; | |
$out = ''; | |
pump $h until length $out; | |
print $cli $out; | |
close $cli; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment