Advertisement
Guest User

Untitled

a guest
Jun 7th, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 6 0.48 KB | None | 0 0
  1. v6.c;
  2.  
  3. sub connect_to {
  4.     my $host = @_[0];
  5.     my $port = @_[1];
  6.  
  7.     my $socket = IO::Socket::Async.connect($host, $port).result;
  8. #    my $socket = IO::Socket::INET.new(:$host, :$port);
  9. #    $socket.say;
  10.     return $socket;
  11. }
  12.  
  13. sub interact {
  14.     my $socket = @_[0];
  15.  
  16.     react {
  17.     whenever $socket.Supply() -> $s {
  18.         $s.say;
  19.     }
  20.     whenever $*IN.Supply() -> $s {
  21.         $socket.print($s);
  22.     }
  23.     }
  24. }
  25.  
  26. my $server = connect_to('localhost', 1234);
  27.  
  28. interact($server);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement