Advertisement
Guest User

Untitled

a guest
Sep 21st, 2016
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 6 0.51 KB | None | 0 0
  1. #server
  2. react {
  3.   whenever IO::Socket::Async.listen('localhost', 3335) -> $conn {
  4.     whenever $conn.Supply(:bin) -> $buf {
  5.       my $str = $buf.decode('UTF-8');
  6.       await $conn.print(($str).encode('UTF-8'));
  7.     }
  8.   }
  9. }
  10.  
  11. #client
  12. await IO::Socket::Async.connect('localhost', 3335).then( -> $conn {
  13.   if $conn.status {
  14.     given $conn.result {
  15.       .print("123");
  16.       react {
  17.         whenever .Supply() -> $v {
  18.           say $v;
  19.           done;
  20.         }
  21.       }
  22.       .close;
  23.     }
  24.   }
  25. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement