Created
December 4, 2012 15:28
-
-
Save tadzik/4205148 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
sub blackbox($sock) { | |
say "Now receiving. This will block"; | |
my $a = $sock.read(10).decode.chomp; | |
say "Now received '$a'"; | |
} | |
my $fakesock = IO::Socket::INET.new(:host<localhost>, :port(31337)) | |
but role { | |
method read($) { | |
say "Lol, I'm intercepting ur read()"; | |
take 1; | |
callsame; | |
} | |
}; | |
say "Silence before the storm"; | |
my @a := gather blackbox($fakesock); | |
say "Now running the blackbox"; | |
@a.shift; | |
say "Now doing the actual receiving"; | |
@a.shift; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment