5 alias original_resolv_getaddress getaddress
8 return Resolv.getaddress(host).to_s
9 rescue Resolv::ResolvError
10 raise SocketError, "Hostname not known: #{host}"
16 alias original_resolv_initialize initialize
17 def initialize(host, serv, *rest)
18 rest[0] = IPSocket.getaddress(rest[0]) unless rest.empty?
19 original_resolv_initialize(IPSocket.getaddress(host), serv, *rest)
24 alias original_resolv_bind bind
26 original_resolv_bind(IPSocket.getaddress(host), port)
29 alias original_resolv_connect connect
30 def connect(host, port)
31 original_resolv_connect(IPSocket.getaddress(host), port)
34 alias original_resolv_send send
35 def send(mesg, flags, *rest)
39 addrs = Resolv.getaddresses(host)
40 rescue Resolv::ResolvError
41 raise SocketError, "Hostname not known: #{host}"
44 addrs[0...-1].each {|addr|
46 return original_resolv_send(mesg, flags, addr, port)
47 rescue SystemCallError
50 original_resolv_send(mesg, flags, addrs[-1], port)
52 original_resolv_send(mesg, flags, *rest)
58 alias original_resolv_initialize initialize
59 def initialize(host, serv)
60 original_resolv_initialize(IPSocket.getaddress(host), port)
62 end if defined? SOCKSSocket