Ejemplo n.º 1
0
        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotArm64Process), nameof(PlatformDetection.IsThreadingSupported))] // [ActiveIssue("https://github.com/dotnet/runtime/issues/27622")]
        public void DnsObsoleteBeginEndGetHostByName_EmptyString_ReturnsHostName()
        {
            IPHostEntry entry = Dns.EndGetHostByName(Dns.BeginGetHostByName("", null, null));

            // DNS labels should be compared as case insensitive for ASCII characters. See RFC 4343.
            Assert.Contains(Dns.GetHostName(), entry.HostName, StringComparison.OrdinalIgnoreCase);
        }
Ejemplo n.º 2
0
        public void AsyncGetHostByName()
        {
            IAsyncResult async = Dns.BeginGetHostByName(site1Name, null, null);
            IPHostEntry  entry = Dns.EndGetHostByName(async);

            SubTestValidIPHostEntry(entry);
            Assert.AreEqual("google-public-dns-a.google.com", entry.HostName, "#1");
        }
Ejemplo n.º 3
0
        public void DnsObsoleteBeginGetHostByName_IPv4String_ReturnsOnlyGivenIP()
        {
            IAsyncResult asyncObject = Dns.BeginGetHostByName(IPAddress.Loopback.ToString(), null, null);
            IPHostEntry  entry       = Dns.EndGetHostByName(asyncObject);

            Assert.Equal(IPAddress.Loopback.ToString(), entry.HostName);
            Assert.Equal(1, entry.AddressList.Length);
            Assert.Equal(IPAddress.Loopback, entry.AddressList[0]);
        }
Ejemplo n.º 4
0
        public void DnsObsoleteBeginGetHostByName_MachineNameWithIPv4_MatchesGetHostByName()
        {
            IAsyncResult asyncObject = Dns.BeginGetHostByName(TestSettings.LocalHost, null, null);
            IPHostEntry  result      = Dns.EndGetHostByName(asyncObject);
            IPHostEntry  entry       = Dns.GetHostByName(TestSettings.LocalHost);

            Assert.Equal(entry.HostName, result.HostName);
            Assert.Equal(entry.AddressList, result.AddressList);
        }
        public void AsyncGetHostByName()
        {
            IAsyncResult r;

            r = Dns.BeginGetHostByName(site1Name, new AsyncCallback(GetHostByNameCallback), null);

            IAsyncResult async = Dns.BeginGetHostByName(site1Name, null, null);
            IPHostEntry  entry = Dns.EndGetHostByName(async);

            SubTestValidIPHostEntry(entry);
            Assert.AreEqual("www.go-mono.com", entry.HostName);
        }
Ejemplo n.º 6
0
        public void AsyncGetHostByName()
        {
            IAsyncResult r;

            r = Dns.BeginGetHostByName(site1Name, new AsyncCallback(GetHostByNameCallback), null);

            IAsyncResult async = Dns.BeginGetHostByName(site1Name, null, null);
            IPHostEntry  entry = Dns.EndGetHostByName(async);

            SubTestValidIPHostEntry(entry);
            Assert.IsTrue(entry.HostName == "jenkins.mono-project.com");
        }
Ejemplo n.º 7
0
        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotArm64Process), nameof(PlatformDetection.IsThreadingSupported))] // [ActiveIssue("https://github.com/dotnet/runtime/issues/27622")]
        public void DnsObsoleteBeginEndGetHostByName_EmptyString_ReturnsHostName()
        {
            if (PlatformDetection.IsSLES)
            {
                // [ActiveIssue("https://github.com/dotnet/runtime/issues/48751")]
                return;
            }

            IPHostEntry entry = Dns.EndGetHostByName(Dns.BeginGetHostByName("", null, null));

            // DNS labels should be compared as case insensitive for ASCII characters. See RFC 4343.
            Assert.Contains(Dns.GetHostName(), entry.HostName, StringComparison.OrdinalIgnoreCase);
        }
Ejemplo n.º 8
0
        public void DnsObsoleteBeginEndGetHostByName_EmptyString_ReturnsHostName()
        {
            if (PlatformDetection.IsSLES ||                                    // [ActiveIssue("https://github.com/dotnet/runtime/issues/55271")]
                PlatformDetection.IsUbuntu1604 || PlatformDetection.IsDebian9) // [ActiveIssue("https://github.com/dotnet/runtime/issues/56295")]
            {
                throw new SkipTestException("Test environment is not configured for this test to work.");
            }

            IPHostEntry entry = Dns.EndGetHostByName(Dns.BeginGetHostByName("", null, null));

            // DNS labels should be compared as case insensitive for ASCII characters. See RFC 4343.
            Assert.Contains(Dns.GetHostName(), entry.HostName, StringComparison.OrdinalIgnoreCase);
        }
Ejemplo n.º 9
0
        static async Task Main(string[] args)
        {
            var x = await Dns.GetHostAddressesAsync("localhost");

            string hostname = Dns.GetHostName();
            var    y        = Dns.EndGetHostByName(Dns.BeginGetHostByName("", null, null));

            Console.WriteLine("My hostname is '{0}'", hostname);
            Console.WriteLine("My ip addresses are:");
            foreach (var address in Dns.GetHostAddresses(hostname))
            {
                Console.WriteLine("\t{0}", address);
            }
        }
Ejemplo n.º 10
0
        public void PipelineRequest(Uri Resource, object Tag)
        {
            object[] stateObject = new object[] { Resource, Tag };
            string   host        = Resource.Host;

            if (Resource.HostNameType == UriHostNameType.Dns)
            {
                Dns.BeginGetHostByName(host, new AsyncCallback(this.GetHostByNameSink), stateObject);
            }
            else
            {
                this.ContinueRequest(new IPEndPoint(IPAddress.Parse(Resource.Host), Resource.Port), HTTPMessage.UnEscapeString(Resource.PathAndQuery), Tag, null);
            }
        }
Ejemplo n.º 11
0
        public void AsyncGetHostByName()
        {
            message = "AsyncGetHostByName";
            reset.Reset();
            IAsyncResult r = Dns.BeginGetHostByName(site, new AsyncCallback(GetHostByNameCallback), null);

            Assert.IsNotNull(r, "IAsyncResult");
            // note for some reason r.AsyncWaitHandle.Wait won't work as expected
            // if (!r.AsyncWaitHandle.WaitOne (timeout, true))
            if (!reset.WaitOne(timeout, true))
            {
                Assert.Ignore("Timeout");
            }
            Assert.IsNull(message, message);
        }
Ejemplo n.º 12
0
        public void AsyncGetHostByNameCallback()
        {
            var       evt = new ManualResetEvent(false);
            Exception ex  = null;

            Dns.BeginGetHostByName(site1Name, new AsyncCallback((IAsyncResult ar) =>
            {
                try {
                    IPHostEntry h;
                    h = Dns.EndGetHostByName(ar);
                    SubTestValidIPHostEntry(h);
                } catch (Exception e) {
                    ex = e;
                } finally {
                    evt.Set();
                }
            }), null);

            Assert.IsTrue(evt.WaitOne(TimeSpan.FromSeconds(60)), "Wait");
            Assert.IsNull(ex, "Exception");
        }
Ejemplo n.º 13
0
    static void Main(string[] args)
    {
        if (args.Length != 0)
        {
            hostname = args[0];
        }
        //  Dns.BeginGetHostByName(hostname,
        //     new AsyncCallback(DnsLookupCompleted), null);

        IAsyncResult ar = Dns.BeginGetHostByName(hostname, null, null);

        while (!ar.IsCompleted)
        {
            Console.WriteLine("Can do something else...");
            System.Threading.Thread.Sleep(100);
        }
        DnsLookupCompleted(ar);

        Console.WriteLine("Waiting for the results...");
        Console.ReadLine();
    }
Ejemplo n.º 14
0
        override internal IAsyncResult BeginConnect(string hostName,
                                                    int port,
                                                    AsyncCallback callback,
                                                    object state)
        {
            CheckDisposed();
            SetProgress(true);
            Connect_SO stateObj = null;

            try
            {
                stateObj = new Connect_SO(port, callback, state);
                Dns.BeginGetHostByName(hostName, new AsyncCallback(GetHost_End), stateObj);
            }
            catch (Exception e)
            {
                SetProgress(false);
                throw e;
            }
            return(stateObj);
        }
Ejemplo n.º 15
0
        public void Connect(string host, int port)
        {
            this.LogWarning.Invoke(string.Format("TcpConnection - Connecting to host: {0}, port: {1}", host, port));
            this.Host = host;
            this.Port = port;
            this.m_candidateIPAddresses = new Queue <IPAddress>();
            IPAddress iPAddress;

            if (IPAddress.TryParse(this.Host, ref iPAddress))
            {
                this.m_candidateIPAddresses.Enqueue(iPAddress);
            }
            try
            {
                Dns.BeginGetHostByName(this.Host, new AsyncCallback(this.GetHostEntryCallback), null);
            }
            catch (Exception ex)
            {
                this.LogWarning.Invoke(string.Format("TcpConnection - Connect() failed, could not get host entry. ip: {0}, port: {1}, exception: {2}", this.Host, this.Port, ex.get_Message()));
                this.OnFailure.Invoke();
            }
        }
Ejemplo n.º 16
0
        private void buttonGetDate_Click(object sender, EventArgs e)
        {
            try
            {
                setThreadedButton(false);
                setThreadedTextBox("");
                setThreadedStatusLabel("Wait! DNS query...");
                /* get DNS host information */
                Dns.BeginGetHostByName("192.168.1.14", new AsyncCallback(GetHostEntryCallback), null);
                //Form2 frm = new Form2(this.fd, this.textBoxLogin.Text.ToString(), endPoint, this);
                frm.Show();
                frm.startReceive();

                //this.Hide();
                // Thread t = new Thread(StartReceiveMess);
                //t.Start();
            }
            catch (Exception exc)
            {
                MessageBox.Show("Exception:\t\n" + exc.Message.ToString());
                setThreadedStatusLabel("Check \"Server Info\" and try again!");
                setThreadedButton(true);
            }
        }
Ejemplo n.º 17
0
 public void PermitOnly_BeginGetHostName()
 {
     Dns.BeginGetHostByName(null, null, null);
 }
Ejemplo n.º 18
0
 public void Connect()
 {
     Status = ConnectionStatus.connecting;
     Dns.BeginGetHostByName(_address, new AsyncCallback(GetHostEntryCallback), null);
 }
Ejemplo n.º 19
0
        public void DnsObsoleteBeginGetHostByName_BadName_Throws()
        {
            IAsyncResult asyncObject = Dns.BeginGetHostByName("BadName", null, null);

            Assert.ThrowsAny <SocketException>(() => Dns.EndGetHostByName(asyncObject));
        }
Ejemplo n.º 20
0
 public void Dns_BeginGetHostByName_CallSocketInit_Ok()
 {
     NameResolutionPal.FakesReset();
     Assert.ThrowsAny <Exception>(() => Dns.BeginGetHostByName(null, null, null));
     Assert.NotEqual(0, NameResolutionPal.FakesEnsureSocketsAreInitializedCallCount);
 }
Ejemplo n.º 21
0
        public void DnsObsoleteBeginEndGetHostByName_EmptyString_ReturnsHostName()
        {
            IPHostEntry entry = Dns.EndGetHostByName(Dns.BeginGetHostByName("", null, null));

            Assert.Contains(Dns.GetHostName(), entry.HostName);
        }
Ejemplo n.º 22
0
 public void Deny_BeginGetHostName()
 {
     Dns.BeginGetHostByName(null, null, null);
 }
Ejemplo n.º 23
0
 static internal IAsyncResult BeginGetHostByName(string hostName, AsyncCallback cb, object state)
 {
     return(Dns.BeginGetHostByName(hostName, cb, state));
 }