public bool Search(string host, QueryType?qtype, string dns, byte[] id) { string _dns = string.IsNullOrEmpty(dns) ? "8.8.8.8" : dns; byte[] _id = id == null?newid() : id; QueryType _qtype = qtype == null ? QueryType.A : (QueryType)qtype; header = new MyDnsHeader(); header.NewID(_id); question = new MyDnsQuestion(); question.Class = QueryClass.IN; question.Type = _qtype; question.Qname = host; byte[] data_head = header.GetBytes(); byte[] data_question = question.GetBytes(); byte[] sendData = new byte[data_head.Length + data_question.Length]; data_head.CopyTo(sendData, 0); data_question.CopyTo(sendData, data_head.Length); byte[] recvData; recvData = udpSend(sendData, _dns); Parse(recvData); return(header.RCODE == 0 ? true : false); }
public bool Search(string host, QueryType? qtype, string dns, byte[] id) { string _dns = string.IsNullOrEmpty(dns) ? "8.8.8.8" : dns; byte[] _id = id == null ? newid() : id; QueryType _qtype = qtype == null ? QueryType.A : (QueryType)qtype; header = new MyDnsHeader(); header.NewID(_id); question = new MyDnsQuestion(); question.Class = QueryClass.IN; question.Type = _qtype; question.Qname = host; byte[] data_head = header.GetBytes(); byte[] data_question = question.GetBytes(); byte[] sendData = new byte[data_head.Length + data_question.Length]; data_head.CopyTo(sendData, 0); data_question.CopyTo(sendData, data_head.Length); byte[] recvData; recvData = udpSend(sendData, _dns); Parse(recvData); return header.RCODE == 0 ? true : false; }