Created
February 8, 2010 15:27
-
-
Save craigw/298233 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# run like this: | |
# sudo ruby -rubygems what_connects.rb 3000 | |
# | |
require 'socket' | |
serv = TCPServer.new(ARGV[0].to_i) | |
begin | |
sock = serv.accept_nonblock | |
rescue Errno::EAGAIN, Errno::ECONNABORTED, Errno::EPROTO, Errno::EINTR | |
IO.select([serv]) | |
retry | |
end | |
puts "Connected to port 3000:" | |
puts %x[lsof -n -i :#{ARGV[0]}].strip | |
sock.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment