#!/usr/bin/env raku
use Digest::MD5;
unit sub MAIN(
:$ip = '127.0.0.1', #= IP to bind
:$port = 8899, #= Port to bind
);
react {
whenever IO::Socket::Async.listen($ip, $port) -> $conn {
my $caddr = $conn.peer-host ~ ':' ~ $conn.peer-port;
say "New client on $caddr";
CLOSE { $conn.close; say "Client on $caddr is gone" }
whenever $conn.Supply.lines -> $line {
$conn.say: md5($line)>>.base(16).join;
}
}
whenever signal(SIGINT) {
say "\rBye !";
exit;
}
say "Listening on tcp://$ip:$port";
}