[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); }
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"); }
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]); }
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); }
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"); }
[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); }
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); }
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); } }
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); } }
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); }
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"); }
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(); }
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); }
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(); } }
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); } }
public void PermitOnly_BeginGetHostName() { Dns.BeginGetHostByName(null, null, null); }
public void Connect() { Status = ConnectionStatus.connecting; Dns.BeginGetHostByName(_address, new AsyncCallback(GetHostEntryCallback), null); }
public void DnsObsoleteBeginGetHostByName_BadName_Throws() { IAsyncResult asyncObject = Dns.BeginGetHostByName("BadName", null, null); Assert.ThrowsAny <SocketException>(() => Dns.EndGetHostByName(asyncObject)); }
public void Dns_BeginGetHostByName_CallSocketInit_Ok() { NameResolutionPal.FakesReset(); Assert.ThrowsAny <Exception>(() => Dns.BeginGetHostByName(null, null, null)); Assert.NotEqual(0, NameResolutionPal.FakesEnsureSocketsAreInitializedCallCount); }
public void DnsObsoleteBeginEndGetHostByName_EmptyString_ReturnsHostName() { IPHostEntry entry = Dns.EndGetHostByName(Dns.BeginGetHostByName("", null, null)); Assert.Contains(Dns.GetHostName(), entry.HostName); }
public void Deny_BeginGetHostName() { Dns.BeginGetHostByName(null, null, null); }
static internal IAsyncResult BeginGetHostByName(string hostName, AsyncCallback cb, object state) { return(Dns.BeginGetHostByName(hostName, cb, state)); }