Question about integrating udns in Ruby EventMachine

Michael Tokarev mjt at tls.msk.ru
Tue Feb 1 13:31:45 MSK 2011


01.02.2011 13:20, Iñaki Baz Castillo wrote:
> Hi, I just wonder if it's possible to integrate udns (as async DNS
> resolver) into Ruby EventMachine (a reactor pattern library written in
> C and C++ for Ruby).
> 
> EventMachine accepts any IO object so it performs non blocking read on
> it and notify the Ruby code when it's readable. So I wonder if the
> following could make sense:
> 
> - I code a Ruby C extension for udns. I need such C code to give me
> the file descriptor in which udns listens for UDP responses from the
> the DNS server.
> 
> - When such responses arrives the fd is readable so EventMachine would
> call a Ruby "notify_readable()" method within the reactor.
> 
> - In that function I could invoke udns rutines for parsing the
> response and, finally, get the DNS query result. I would translate
> such result into Ruby code.

That's exactly how it should be used, and yes, it makes perfect
sense...

> I don't know if this idea makes sense. Does it? For it, it would be
> required that udns lets me to access its file descriptor instead of
> udns directly managing it.

..but this part - I don't understand it.  Why do you want to "stole"
a filedescriptor from udns, why notify_readable() can't call udns
routine directly?

Also, don't forget about timeouts (timers).

/mjt


More information about the udns mailing list