Skip to content

Commit

Permalink
Make unsuccessful connect fail rather than die
Browse files Browse the repository at this point in the history
Spotted in https://stackoverflow.com/questions/72639883/how-to-deal-with-exceptions-in-iosocketinet

There is no documentation or tests covering the behaviour of a failed
connect.  It is actually the nqp::connect that throws (which turns out
also to be not documented BTW).

Having it return a Failure feels more natural indeed.
  • Loading branch information
lizmat committed Jun 16, 2022
1 parent d253dc7 commit 14baac4
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/core.c/IO/Socket/INET.pm6
Expand Up @@ -113,6 +113,7 @@ my class IO::Socket::INET does IO::Socket {
#?endif
}
elsif $!type == SOCK_STREAM {
CATCH { return .Failure }
nqp::connect($PIO, nqp::unbox_s($!host), nqp::unbox_i($!port), nqp::decont_i($!family));
}

Expand Down

0 comments on commit 14baac4

Please sign in to comment.