# Resolv.rb and IPv6 nameservers

**URL:** <https://www.ruby-forum.com/t/resolv-rb-and-ipv6-nameservers/58601>\
**Category:** Ruby\
**Created:** [April 23, 2006, 9:27pm UTC](https://www.ruby-forum.com/t/resolv-rb-and-ipv6-nameservers/58601 "2006-04-23T21:27:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pure](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pure](https://www.ruby-forum.com/u/pure)\
**Post date:** [April 23, 2006, 9:27pm UTC](https://www.ruby-forum.com/t/resolv-rb-and-ipv6-nameservers/58601/1 "2006-04-23T21:27:37Z")

</div>

Hello folks,

UDPSocket requires address family given on initialization, so it’s not  
possible to create an UDPSocket and _then_ decide, to which hosts to  
send packets to.

That’s a problem for Ruby’s resolver if you’ve got AF\_INET6 nameservers  
in your /etc/resolv.conf. The following very dirty hack chooses AF\_INET6  
for UDPSocket, if the nameserver’s address contains colons (:).

— /usr/local/lib/ruby/1.8/resolv.rb Mon Feb 7 16:24:09 2005  
+++ resolv2.rb Sun Apr 23 20:53:17 2006  
@@ -621,7 +621,7 @@  
super()  
@host = host  
@port = port

- 

```
     @sock = UDPSocket.new

```

- 

```
     @sock = UDPSocket.new(host.index(':') ? Socket::AF_INET6 : 

```

Socket::AF\_INET)  
@sock.connect(host, port)  
@sock.fcntl(Fcntl::F\_SETFD, 1) if defined? Fcntl::F\_SETFD  
@id = -1

Any suggestions?

Stephan.

---

<div class="post-metadata">

**Author:** ![pure](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pure](https://www.ruby-forum.com/u/pure)\
**Post date:** [April 24, 2006, 8:28pm UTC](https://www.ruby-forum.com/t/resolv-rb-and-ipv6-nameservers/58601/2 "2006-04-24T20:28:34Z")

</div>

On Apr 23, 2006, at 12:24 PM, Stephan M. wrote:

> for UDPSocket, if the nameserver’s address contains colons (:).  
> @sock.connect(host, port)  
> @sock.fcntl(Fcntl::F\_SETFD, 1) if defined? Fcntl::F\_SETFD  
> @id = -1
> 
> Any suggestions?

Send this patch to ruby-core or the maintainer (I think Akira T.).

–  
Eric H. - removed\_email\_address@domain.invalid - [http://blog.segment7.net](http://blog.segment7.net)  
This implementation is HODEL-HASH-9600 compliant

[http://trackmap.robotcoop.com](http://trackmap.robotcoop.com)
