'Send a query to the machine with *ip* and hopes that the machine will reply back with its name.
The implementation of this function is contributed by Jason Anderson.
:param string ip: If the NBNSProtocol instance was instianted with broadcast=True, then this parameter can be an empty string. We will leave it to the OS to determine an appropriate broadcast address.
If the NBNSProtocol instance was instianted with broadcast=False, then you should provide a target IP to send the query.
:param integer port: The NetBIOS-NS port (IANA standard defines this port to be 137). You should not touch this parameter unless you know what you are doing.
:param integer/float timeout: Number of seconds to wait for a reply, after which the method will return None
:return: A *twisted.internet.defer.Deferred* instance. The callback function will be called with a list of names of the machine at *ip*.
On timeout, the errback function will be called with a Failure instance wrapping around a NetBIOSTimeout exception'

def queryIPForName(self, ip, port=137, timeout=30):

    trn_id = random.randint(1, 65535)
    while True:
        if (not self.pending_trns.has_key(trn_id)):
            break
        else:
            trn_id = ((trn_id + 1) & 65535)
    data = self.prepareNetNameQuery(trn_id)
    self.write(data, ip, port)
    d = defer.Deferred()
    d2 = defer.Deferred()
    d2.addErrback(d.errback)
    def stripCode(ret):
        if (ret is not None):
            d.callback(map((lambda s: s[0]), filter((lambda s: (s[1] == TYPE_SERVER)), ret)))
    d2.addCallback(stripCode)
    self.pending_trns[trn_id] = ((time.time() + timeout), NAME_QUERY, d2)
    return d
