LoginSignup
15
15

More than 5 years have passed since last update.

使ってないポートを取得する

Last updated at Posted at 2012-03-16

サーバのテストとか書いてると,空いてるポートが欲しくなるので

def unused_port
  s = TCPServer.open(0)
  port = s.addr[1]
  s.close
  port
end
15
15
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
15