[#7872] Nonblocking socket-connect — "Francis Cianfrocca" <garbagecat10@...>

All, I needed a nonblocking socket connect for my asynchronous-event

18 messages 2006/05/14
[#7873] Re: Nonblocking socket-connect — Tanaka Akira <akr@...17n.org> 2006/05/14

In article <3a94cf510605140559l7baa0205le341dac4f47d424b@mail.gmail.com>,

[#7874] Re: Nonblocking socket-connect — "Francis Cianfrocca" <garbagecat10@...> 2006/05/15

How about introducing the method Socket#set_nonblocking, or alternatively

[#7875] Re: Nonblocking socket-connect — Yukihiro Matsumoto <matz@...> 2006/05/15

Hi,

[#7876] Re: Nonblocking socket-connect — "Francis Cianfrocca" <garbagecat10@...> 2006/05/15

Well, it's ok then. I'm comfortable adding in the nonblocking

[#7877] Re: Nonblocking socket-connect — Yukihiro Matsumoto <matz@...> 2006/05/15

Hi,

Resolv::DNS and IPv6 nameservers

From: Stephan Maka <stephan@...>
Date: 2006-05-06 02:56:33 UTC
List: ruby-core #7831
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.

In This Thread

Prev Next