Created
March 20, 2016 17:24
-
-
Save ugexe/fb1b470fc07650400c98 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
my role IO::Streamable::Socket[*%connect-opts] { | |
# Fake enough of the interface to be viable | |
has $.socket; | |
has $!IO handles 'slurp-rest'; | |
method open { | |
$!IO //= do { | |
my $tmpfile = $*TMPDIR.child("{time}.{$*PID}"); | |
$!socket.?connect(|%connect-opts); | |
$!socket.?send('possible handshake/init stuff'); | |
$tmpfile.spurt: $!socket.recv(:bin); | |
$tmpfile; | |
} | |
} | |
} | |
my $h = IO::Handle.new(:path('-')) but IO::Streamable::Socket[:host<localhost>]; | |
...; $h.open.slurp-rest; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment