Skip to content

Instantly share code, notes, and snippets.

@tadzik
Created December 4, 2012 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tadzik/4205148 to your computer and use it in GitHub Desktop.
Save tadzik/4205148 to your computer and use it in GitHub Desktop.
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