+function resolver:feed(sock, packet)
+ --print 'receive' print (self.socket)
+ self.time = socket.gettime ()
+
+ local response = self:decode (packet)
+ if response then
+ --print 'received response'
+ --self.print (response)
+
+ for i,section in pairs { 'answer', 'authority', 'additional' } do
+ for j,rr in pairs (response[section]) do
+ self:remember (rr, response.question[1].type)
+ end
+ end
+
+ -- retire the query
+ local queries = self.active[response.header.id]
+ if queries[response.question.raw] then
+ queries[response.question.raw] = nil
+ end
+ if not next (queries) then self.active[response.header.id] = nil end
+ if not next (self.active) then self:closeall () end
+
+ -- was the query on the wanted list?
+ local q = response.question[1]
+ if q then
+ local cos = get (self.wanted, q.class, q.type, q.name)
+ if cos then
+ for co in pairs (cos) do
+ set (self.yielded, co, q.class, q.type, q.name, nil)
+ if coroutine.status(co) == "suspended" then coroutine.resume (co) end
+ end
+ set (self.wanted, q.class, q.type, q.name, nil)
+ end
+ end
+ end
+
+ return response
+end
+
+function resolver:cancel(data)
+ local cos = get (self.wanted, unpack(data, 1, 3))
+ if cos then
+ cos[data[4]] = nil;
+ end
+end
+