Sample server:
#!/usr/bin/env perl6
my $listen = IO::Socket::INET.new(:listen, :localhost<localhost>, :localport(3333));
loop {
my $conn = $listen.accept;
while my $buf = $conn.recv(:bin) {
$conn.write: $buf;
}
$conn.close;
}
Client:
#!/use/bin/env perl6
my $c = IO::Socket::INET.new(:host<localhost>, :port(3333));
$c.print: "{time}\n";
#say $c.recv; #commented out on purpose
sleep 1 ;
$c.close ;
server error:
Could not receive data from socket: Connection reset by peer
in block <unit> at server4.p6 line 5
In the server on each of the blocks I tried CATCH
and QUIT
. How should I catch this error?