Guest User

Untitled

a guest
Apr 25th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #!/usr/bin/env perl6
  2. my $port = 3333 ;
  3. say "listen port $port" ;
  4.  
  5. react {
  6. my $ids = 0 ;
  7. whenever IO::Socket::Async.listen('0.0.0.0', $port ) -> $conn {
  8. my $id = $ids++ ;
  9. $conn.print( "$id: hellon") ;
  10. whenever $conn.Supply.lines -> $line {
  11. say "$id: $line" ;
  12. $conn.print( "$id : $linen") ;
  13. }
  14. }
  15. }
  16.  
  17. #!/usr/bin/env perl6
  18. my $port = 3333 ;
  19. my $conn = await IO::Socket::Async.connect('localhost', $port );
  20. $conn.print: "{time}n";
  21.  
  22. #$conn.Supply.tap(-> $v { print $v });
  23.  
  24. sleep 1 ;
  25. $conn.close;
  26.  
  27. listen port 3333
  28. 0: 1524671069
  29. An operation first awaited:
  30. in block <unit> at ./server2.p6 line 5
  31.  
  32. Died with the exception:
  33. connection reset by peer
  34. in block <unit> at ./server2.p6 line 5
  35.  
  36. X::AdHoc+{X::Await::Died}: connection reset by peer
Add Comment
Please, Sign In to add comment