Skip to content

Commit

Permalink
Place a try catch block in the socket example.
Browse files Browse the repository at this point in the history
As for issue #1963 it seems that without the try-catch the loop can crash
the server if the client does wait (sleep) or do something strange with the
incoming data.
Seems to me a flushing problem.

Tested on moar 2018.04.
  • Loading branch information
fluca1978 committed Apr 28, 2018
1 parent 9fc190d commit 65c285c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions doc/Type/IO/Socket/INET.pod6
Expand Up @@ -18,10 +18,17 @@ my $listen = IO::Socket::INET.new( :listen,
:localport(3333) );
loop {
my $conn = $listen.accept;
while my $buf = $conn.recv(:bin) {
$conn.write: $buf;
try {
while my $buf = $conn.recv(:bin) {
$conn.write: $buf;
}
}
$conn.close;
CATCH {
default { .payload.say; }
}
}
=end code
Expand Down

0 comments on commit 65c285c

Please sign in to comment.