Skip to content

Instantly share code, notes, and snippets.

@benweint
Created August 13, 2014 16:37
Show Gist options
  • Save benweint/cad9ca369735d1c23c78 to your computer and use it in GitHub Desktop.
Save benweint/cad9ca369735d1c23c78 to your computer and use it in GitHub Desktop.
getaddrinfo and TCPSocket.new
#!/usr/bin/env ruby
require 'socket'
require 'resolv'
require 'resolv-replace'
puts "Run this to trace getaddrinfo calls:"
puts "sudo dtrace -p #{$$} -n 'pid$target::getaddrinfo:entry { ustack(); }'"
loop do
puts "Opening!"
s = TCPSocket.open("google.com", 80)
s.close
sleep 5
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment