From: "Guy N. Hurst" Date: 2002-04-19T11:27:00+09:00 Subject: Re: resolv.rb Bug "Roy J. Milican" wrote: > ... > nnsn> After applying the second patch, you need to close the DNS > nnsn> object explicitly, or use DNS.open with a block. > > Could you give me an example. Sorry if I'm being dumb here but my > patched version is still doing the "Too many files open" thing. > Since > I didn't know what you ment quite by close the DNS object explicitly > I > changed my DNS.new to DNS.open, no error running it but it still > gives > me the too many files error after 256 times. This is the code I'm > using. > > domainrecord = Resolv::DNS.open.getresources(@domain, > Resolv::DNS::Resource::IN::MX).collect{|r| [r.exchange.to_s, > r.preference]} > > Any help would be appriated. > "open with a block" means: DNS.open{|x| x.do_stuff } (as opposed to "DNS.open.do_stuff") The block form will ensure that what was opened gets closed when the block is done. Guy N. Hurst