Guest User

Untitled

a guest
Jul 22nd, 2014
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 6 0.45 KB | None | 0 0
  1. sub async($fn) {
  2.     Thread.start($fn);
  3.     say "started";
  4. }
  5.  
  6. my $socket = IO::Socket::INET.new:
  7.     localhost => 'localhost',
  8.     localport => 12321,
  9.     listen    => 1;
  10.  
  11. while $socket.accept -> $conn {
  12.     say "Accepted connection";
  13.     async {
  14.         say "got in here";
  15.         while $conn.recv -> $stuff {
  16.             say "Echoing $stuff";
  17.             $conn.send($stuff);
  18.         }
  19.         $conn.close;
  20.         say "closed";
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment