#! /usr/bin/env perl6
use v6;
react {
whenever IO::Socket::Async.listen('0.0.0.0', 3333) -> $conn {
my $time = now;
Promise.in(4).then({
if (now - $time > 4) {
$conn.print("TIMEOUT\n");
$conn.close;
}
});
whenever $conn.Supply.lines -> $line {
$time = now;
Promise.in(4).then({
if (now - $time > 4) {
$conn.print("TIMEOUT\n");
$conn.close;
}
});
$conn.print("$line\n");
}
}
whenever signal(SIGINT) { done(); exit; }
}