Class: UDPSocket
- Inherits:
-
Object
- Object
- UDPSocket
- Defined in:
- lib/net/dns/resolv-replace.rb
Instance Method Summary collapse
- #bind(host, port) ⇒ Object
- #connect(host, port) ⇒ Object
- #original_resolv_bind ⇒ Object
- #original_resolv_connect ⇒ Object
- #original_resolv_send ⇒ Object
- #send(mesg, flags, *rest) ⇒ Object
Instance Method Details
#bind(host, port) ⇒ Object
29 30 31 |
# File 'lib/net/dns/resolv-replace.rb', line 29 def bind(host, port) original_resolv_bind(IPSocket.getaddress(host), port) end |
#connect(host, port) ⇒ Object
34 35 36 |
# File 'lib/net/dns/resolv-replace.rb', line 34 def connect(host, port) original_resolv_connect(IPSocket.getaddress(host), port) end |
#original_resolv_bind ⇒ Object
28 |
# File 'lib/net/dns/resolv-replace.rb', line 28 alias original_resolv_bind bind |
#original_resolv_connect ⇒ Object
33 |
# File 'lib/net/dns/resolv-replace.rb', line 33 alias original_resolv_connect connect |
#original_resolv_send ⇒ Object
38 |
# File 'lib/net/dns/resolv-replace.rb', line 38 alias original_resolv_send send |
#send(mesg, flags, *rest) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/net/dns/resolv-replace.rb', line 39 def send(mesg, flags, *rest) if rest.length == 2 host, port = rest begin addrs = Resolv.getaddresses(host) rescue Resolv::ResolvError raise SocketError, "Hostname not known: #{host}" end err = nil addrs[0...-1].each {|addr| begin return original_resolv_send(mesg, flags, addr, port) rescue SystemCallError end } original_resolv_send(mesg, flags, addrs[-1], port) else original_resolv_send(mesg, flags, *rest) end end |