Why doesn't my dns server work?

Sep 24, 2012 at 3:27 PM

why must programe can not work correctly.

does your library work with asynchronization?

I used the server code example on your site,but the exe file can only receive my input strin ,it doesn't process any UDP packets.what's wrong with it?

From:http://docs.ar-soft.de/arsoft.tools.net/DNS%20Server.html

 

class Program
{
  static void Main(string[] args)
  {
    using (DnsServer server = new DnsServer(IPAddress.Any, 10, 10, ProcessQuery))
    {
      server.Start();
      Console.WriteLine("Press any key to stop server");
      Console.ReadLine();
    }
  }
 
  static DnsMessageBase ProcessQuery(DnsMessageBase message, IPAddress clientAddress, ProtocolType protocol)
  {
    // It doesn't run into this function any all! what's wrong with it ?

    message.IsQuery = false;
    DnsMessage query = message as DnsMessage;
    // check for valid query
    if ((query != null)
      && (query.Questions.Count == 1)
      && (query.Questions[0].RecordType == RecordType.Txt)
      && (query.Questions[0].Name.Equals("example.com", StringComparison.InvariantCultureIgnoreCase)))
    {
      query.ReturnCode = ReturnCode.NoError;
      query.AnswerRecords.Add(new TxtRecord("example.com", 3600, "Hello world"));
    }
    else
    {
      message.ReturnCode = ReturnCode.ServerFailure;
    }
    return message;
  }
}


Sep 24, 2012 at 5:01 PM

OK.I solved the problem.

My Windows firewall is working :-( ///