Esempio n. 1
0
        public void Initalize()
        {
            NetTrace.Start();
            NetTrace.Enable(DnsResolver.TraceSubSystem, 0);

            DnsResolver.Bind();
        }
Esempio n. 2
0
        public void DnsResolver_Bind_CancelException()
        {
            IPAddress    dns = IPAddress.Loopback;
            DnsRequest   request;
            DnsResponse  response;
            IAsyncResult ar;

            // This test sends a DNS request to the loopback address
            // assuming that there is no DNS server running locally
            // and then calls DnsResolver.Bind() which should terminate
            // the query with a CancelException.

            request = new DnsRequest(DnsFlag.RD, "www.lilltek.com.", DnsQType.A);
            ar      = DnsResolver.BeginQuery(dns, request, timeout, null, null);

            DnsResolver.Bind();
            try
            {
                response = DnsResolver.EndQuery(ar);
                Assert.Fail("Expected a CancelException");
            }
            catch (CancelException)
            {
            }
            catch
            {
                Assert.Fail("Expected a CancelException");
            }
            finally
            {
                Thread.Sleep(1000);     // $todo(jeff.lill):
                //
                // This test causes some problems for some other
                // tests unless I add this (I'm not sure why).
            }
        }
Esempio n. 3
0
 public void Cleanup()
 {
     DnsResolver.Bind();
     NetTrace.Stop();
 }
Esempio n. 4
0
        public void DnsResolver_Multiple_Lookup_Bind()
        {
            // This test repeats the A_Multiple test, but this time
            // after binding the DnsResolver to 5 client side sockets.

            IPAddress dns = GetDns();

            string[] gtld = new string[] {
                "a.gtld-servers.net.",
                "b.gtld-servers.net.",
                "c.gtld-servers.net.",
                "d.gtld-servers.net.",
                "e.gtld-servers.net.",
                "f.gtld-servers.net.",
                "g.gtld-servers.net.",
                "h.gtld-servers.net.",
                "i.gtld-servers.net.",
                "j.gtld-servers.net.",
                "k.gtld-servers.net.",
                "l.gtld-servers.net.",
                "m.gtld-servers.net.",
            };

            DnsRequest[]   requests  = new DnsRequest[gtld.Length];
            DnsResponse[]  responses = new DnsResponse[gtld.Length];
            IAsyncResult[] rgAR      = new IAsyncResult[gtld.Length];
            IPEndPoint[]   clientEPs;

            clientEPs = new IPEndPoint[10];
            for (int i = 0; i < clientEPs.Length; i++)
            {
                clientEPs[i] = new IPEndPoint(IPAddress.Any, 0);
            }

            DnsResolver.Bind(clientEPs, 128 * 1024, 128 * 1024);

            try
            {
                for (int j = 0; j < 10; j++)
                {
                    // Repeat the test 10 times just for fun

                    for (int i = 0; i < gtld.Length; i++)
                    {
                        requests[i] = new DnsRequest(DnsFlag.RD, gtld[i], DnsQType.A);
                    }

                    for (int i = 0; i < gtld.Length; i++)
                    {
                        rgAR[i] = DnsResolver.BeginQuery(dns, requests[i], timeout, null, null);
                    }

                    for (int i = 0; i < gtld.Length; i++)
                    {
                        responses[i] = DnsResolver.EndQuery(rgAR[i]);
                    }

                    for (int i = 0; i < gtld.Length; i++)
                    {
                        Assert.AreEqual(requests[i].QID, responses[i].QID);
                        Assert.AreEqual(requests[i].QName, responses[i].QName);
                    }
                }
            }
            finally
            {
                DnsResolver.Bind();
            }
        }