Skip to content

Instantly share code, notes, and snippets.

@AlexDaniel
Last active November 28, 2019 19:33
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 AlexDaniel/00198fac369062afb76cc35a435f70ef to your computer and use it in GitHub Desktop.
Save AlexDaniel/00198fac369062afb76cc35a435f70ef to your computer and use it in GitHub Desktop.
start {
react {
whenever IO::Socket::Async.listen('localhost', 3333) -> $connection {
whenever $connection.Supply.lines -> $line {
die unless $line eq 'ping'; # just checking...
$connection.print( "pong\n" );
}
}
}
}
sleep 0.3;
my $connection = IO::Socket::INET.new( host => 'localhost', port => 3333 );
my $start = now;
for ^50000 {
$connection.put( 'ping' );
my $status = $connection.get( );
die unless $status eq 'pong'; # just checking...
}
my $time = now - $start;
say $time;
exit 42 if $time < 7;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment