Skip to content

Instantly share code, notes, and snippets.

@jonathanstowe
Created July 2, 2015 12:08
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 jonathanstowe/40ae924c79342d3ac244 to your computer and use it in GitHub Desktop.
Save jonathanstowe/40ae924c79342d3ac244 to your computer and use it in GitHub Desktop.
Async echo client example
await IO::Socket::Async.connect('localhost',3333).then( -> $p {
if $p.status == Kept {
my $conn = $p.result;
my $p2 = $conn.send('Hello, Perl 6');
my $p3 = Promise.new;
$conn.chars_supply.tap(-> $str { say $str; $p3.keep});
await $p3;
$conn.close;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment