[ruby-list:50503] Re: [質問] net/http.rb 内 method の一部のraise抑止したい
From:
<yamataka@...08.itscom.net>
Date:
2017-03-14 09:05:26 UTC
List:
ruby-list #50503
山口です。
> 内海@ベルギーです
>
> ご自作のスクリプトがわからないのですが、
説明が足りない状態でのアドバイスありがとうございます。
> ポートが開いているかを確認してから呼べばよいのでは?
>
> require 'socket'
>
> def is_open?(port)
> begin
> socket = TCPSocket.open("localhost", port)
> socket.close
> return true
> rescue Exception => e
> puts e.to_s
> return false
> end
> end
望み通りの対応できました。
> 的外れだったらすみません。
的確なアドバイスありがとうございます。
raiseを抑止する事ばかりに意識が行っていたので、目から鱗です。