| CODENOTIFIER | HelpYou are not signed inSign in |
Project: rev
Revision: 241
Author: rogerdpack
Date: 01 Aug 2008 00:51:52
Changes:cycle through nameservers [which overcame a small problem I was having], and also add some socket options...not sure if this is exactly what wanted but it could be
Files:| ... | ...@@ -98,6 +98,8 @@ | |
| 98 | 98 | |
| 99 | 99 | # Send a request to the DNS server |
| 100 | 100 | def send_request |
| 101 | nameserver = @nameservers.shift | |
| 102 | @nameservers << nameserver # rotate them | |
| 101 | 103 | @socket.connect @nameservers.first, DNS_PORT |
| 102 | 104 | begin |
| 103 | 105 | @socket.send request_message, 0 |
| ... | ...@@ -108,7 +110,11 @@ | |
| 108 | 110 | |
| 109 | 111 | # Called by the subclass when the DNS response is available |
| 110 | 112 | def on_readable |
| 111 | datagram = @socket.recvfrom_nonblock(DATAGRAM_SIZE).first | |
| 113 | datagram = nil | |
| 114 | begin | |
| 115 | datagram = @socket.recvfrom_nonblock(DATAGRAM_SIZE).first | |
| 116 | rescue Errno::ECONNREFUSED | |
| 117 | end | |
| 112 | 118 | address = response_address datagram rescue nil |
| 113 | 119 | address ? on_success(address) : on_failure |
| 114 | 120 | detach |
| ... | ...@@ -61,6 +61,9 @@ | |
| 61 | 61 | if connect_successful? |
| 62 | 62 | @rev_socket.instance_eval { @_connector = nil } |
| 63 | 63 | @rev_socket.attach(evl) |
| 64 | @ruby_socket.setsockopt(::Socket::IPPROTO_TCP, ::Socket::TCP_NODELAY, [1].pack("l")) | |
| 65 | @ruby_socket.setsockopt(::Socket::SOL_SOCKET, ::Socket::SO_KEEPALIVE, true) | |
| 66 | ||
| 64 | 67 | @rev_socket.__send__(:on_connect) |
| 65 | 68 | else |
| 66 | 69 | @rev_socket.instance_eval { @_failed = true } |