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 host = IPSocket.getaddress(host) if host != ""
27 original_resolv_bind(host, port)
30 alias original_resolv_connect connect
31 def connect(host, port)
32 original_resolv_connect(IPSocket.getaddress(host), port)
35 alias original_resolv_send send
36 def send(mesg, flags, *rest)
40 addrs = Resolv.getaddresses(host)
41 rescue Resolv::ResolvError
42 raise SocketError, "Hostname not known: #{host}"
45 addrs[0...-1].each {|addr|
47 return original_resolv_send(mesg, flags, addr, port)
48 rescue SystemCallError
51 original_resolv_send(mesg, flags, addrs[-1], port)
53 original_resolv_send(mesg, flags, *rest)
59 alias original_resolv_initialize initialize
60 def initialize(host, serv)
61 original_resolv_initialize(IPSocket.getaddress(host), port)
63 end if defined? SOCKSSocket