如何处理IO :: socket :: inet中的例外?
假设Localhost的端口12340没有侦听应用程序。
下面的命令不应该打印“错误”吗?
$ raku -e "IO::Socket::INET.new(:host('localhost'), :port(12340)) or die 'error'"
Could not connect socket: No connection could be made because the target machine actively refused it.
in block <unit> at -e line 1
Assume there's no application listening at port 12340 in localhost.
Shouldn't the command below print "error" ?
$ raku -e "IO::Socket::INET.new(:host('localhost'), :port(12340)) or die 'error'"
Could not connect socket: No connection could be made because the target machine actively refused it.
in block <unit> at -e line 1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
nqp ::连接
的当前实现是建立连接的基础逻辑,将x :: adhoc
异常。拥有io :: socket :: inet.new
返回失败
如果无法连接,对我来说确实更有意义。我已经创建了一个拉请求创建此行为。
在此之前,您可以在本地使用相同的代码更改:
The current implementation of
nqp::connect
, the underlying logic to make the connection, throws anX::AdHoc
exception. HavingIO::Socket::INET.new
return aFailure
if not able to connect, would make more sense to me indeed.I've created a Pull Request to create this behaviour.
Until then, you can use the same code change locally: