c#dns解析示例

简介:
2007-11-22 16:05

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Net;
namespace WindowsApplication2
{

/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
   private System.Windows.Forms.Label label1;
   private System.Windows.Forms.Label label2;
   private System.Windows.Forms.TextBox ip1;
   private System.Windows.Forms.TextBox domain1;
   private System.Windows.Forms.TextBox domain2;
   private System.Windows.Forms.Label label3;
   private System.Windows.Forms.TextBox ip2;
   private System.Windows.Forms.Button button1;
   private System.Windows.Forms.Button button2;
   private System.Windows.Forms.Label label4;
   private System.Windows.Forms.Label label5;
   /// <summary>
   /// 必需的设计器变量。
   /// </summary>
   /// 
  
   private System.ComponentModel.Container components = null;

   public Form1()
   {
    //
    // Windows 窗体设计器支持所必需的
    //
    InitializeComponent();

    //
    // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
    //
   }

   /// <summary>
   /// 清理所有正在使用的资源。
   /// </summary>
   protected override void Dispose( bool disposing )
   {
    if( disposing )
    {
     if (components != null) 
     {
      components.Dispose();
     }
    }
    base.Dispose( disposing );
   }

   #region Windows 窗体设计器生成的代码
   /// <summary>
   /// 设计器支持所需的方法 - 不要使用代码编辑器修改
   /// 此方法的内容。
   /// </summary>
   private void InitializeComponent()
   {
    this.label1 = new System.Windows.Forms.Label();
    this.label2 = new System.Windows.Forms.Label();
    this.ip1 = new System.Windows.Forms.TextBox();
    this.domain1 = new System.Windows.Forms.TextBox();
    this.domain2 = new System.Windows.Forms.TextBox();
    this.label3 = new System.Windows.Forms.Label();
    this.ip2 = new System.Windows.Forms.TextBox();
    this.button1 = new System.Windows.Forms.Button();
    this.button2 = new System.Windows.Forms.Button();
    this.label4 = new System.Windows.Forms.Label();
    this.label5 = new System.Windows.Forms.Label();
    this.SuspendLayout();
    // 
    // label1
    // 
    this.label1.Location = new System.Drawing.Point(136, 16);
    this.label1.Name = "label1";
    this.label1.TabIndex = 0;
    this.label1.Text = "域名解析";
    // 
    // label2
    // 
    this.label2.Location = new System.Drawing.Point(144, 56);
    this.label2.Name = "label2";
    this.label2.Size = new System.Drawing.Size(72, 16);
    this.label2.TabIndex = 1;
    this.label2.Text = "IP--〉域名";
    // 
    // ip1
    // 
    this.ip1.Location = new System.Drawing.Point(16, 56);
    this.ip1.Name = "ip1";
    this.ip1.Size = new System.Drawing.Size(120, 21);
    this.ip1.TabIndex = 2;
    this.ip1.Text = "textBox1";
    // 
    // domain1
    // 
    this.domain1.Location = new System.Drawing.Point(224, 56);
    this.domain1.Name = "domain1";
    this.domain1.Size = new System.Drawing.Size(144, 21);
    this.domain1.TabIndex = 3;
    this.domain1.Text = "textBox2";
    // 
    // domain2
    // 
    this.domain2.Location = new System.Drawing.Point(16, 104);
    this.domain2.Name = "domain2";
    this.domain2.Size = new System.Drawing.Size(120, 21);
    this.domain2.TabIndex = 4;
    this.domain2.Text = "textBox1";
    // 
    // label3
    // 
    this.label3.Location = new System.Drawing.Point(144, 104);
    this.label3.Name = "label3";
    this.label3.Size = new System.Drawing.Size(64, 23);
    this.label3.TabIndex = 5;
    this.label3.Text = "域名->ip";
    // 
    // ip2
    // 
    this.ip2.Location = new System.Drawing.Point(224, 104);
    this.ip2.Name = "ip2";
    this.ip2.Size = new System.Drawing.Size(144, 21);
    this.ip2.TabIndex = 6;
    this.ip2.Text = "textBox1";
    // 
    // button1
    // 
    this.button1.Location = new System.Drawing.Point(384, 56);
    this.button1.Name = "button1";
    this.button1.TabIndex = 7;
    this.button1.Text = "确定";
    this.button1.Click += new System.EventHandler(this.button1_Click);
    // 
    // button2
    // 
    this.button2.Location = new System.Drawing.Point(384, 104);
    this.button2.Name = "button2";
    this.button2.TabIndex = 8;
    this.button2.Text = "确定";
    this.button2.Click += new System.EventHandler(this.button2_Click);
    // 
    // label4
    // 
    this.label4.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(192)), ((System.Byte)(128)));
    this.label4.Location = new System.Drawing.Point(168, 224);
    this.label4.Name = "label4";
    this.label4.Size = new System.Drawing.Size(248, 23);
    this.label4.TabIndex = 9;
    this.label4.Text = "网络05玄魂制作";
    // 
    // label5
    // 
    this.label5.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(255)), ((System.Byte)(255)));
    this.label5.Location = new System.Drawing.Point(168, 184);
    this.label5.Name = "label5";
    this.label5.Size = new System.Drawing.Size(248, 23);
    this.label5.TabIndex = 10;
    this.label5.Text = "运行环境framework1.1以上";
    // 
    // Form1
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
    this.ClientSize = new System.Drawing.Size(472, 273);
    this.Controls.Add(this.label5);
    this.Controls.Add(this.label4);
    this.Controls.Add(this.button2);
    this.Controls.Add(this.button1);
    this.Controls.Add(this.ip2);
    this.Controls.Add(this.label3);
    this.Controls.Add(this.domain2);
    this.Controls.Add(this.domain1);
    this.Controls.Add(this.ip1);
    this.Controls.Add(this.label2);
    this.Controls.Add(this.label1);
    this.Name = "Form1";
    this.Text = "Form1";
    this.Load += new System.EventHandler(this.Form1_Load);
    this.ResumeLayout(false);

   }
   #endregion

   /// <summary>
   /// 应用程序的主入口点。
   /// </summary>
   [STAThread]
   
  
   static void Main() 
   {
    Application.Run(new Form1());
   }

   private void Form1_Load(object sender, System.EventArgs e)
   {
  
   }

   private void button1_Click(object sender, System.EventArgs e)
   {
    string adr=" ";
    adr=ip1.Text;
    IPHostEntry IPHost = Dns.Resolve(adr);
   string names = IPHost.HostName;
    domain1.Text = names;
   }

   private void button2_Click(object sender, System.EventArgs e)
   {
    string name=" ",adr=" ";
    name = domain2.Text;
    IPHostEntry IPHost = Dns.Resolve(name);
    IPAddress[] addr= IPHost.AddressList;
    for(int i=0;i<addr.Length;i++)
    {
     adr+=addr[i];

    }
ip2.Text = adr;

   }
}
}


本文转自悬魂博客园博客,原文链接:http://www.cnblogs.com/xuanhun/archive/2010/02/03/1662420.html,如需转载请自行联系原作者
相关文章
|
2月前
|
XML 前端开发 C#
C#编程实践:解析HTML文档并执行元素匹配
通过上述步骤,可以在C#中有效地解析HTML文档并执行元素匹配。HtmlAgilityPack提供了一个强大而灵活的工具集,可以处理各种HTML解析任务。
135 19
|
6月前
|
存储 算法 安全
如何控制上网行为——基于 C# 实现布隆过滤器算法的上网行为管控策略研究与实践解析
在数字化办公生态系统中,企业对员工网络行为的精细化管理已成为保障网络安全、提升组织效能的核心命题。如何在有效防范恶意网站访问、数据泄露风险的同时,避免过度管控对正常业务运作的负面影响,构成了企业网络安全领域的重要研究方向。在此背景下,数据结构与算法作为底层技术支撑,其重要性愈发凸显。本文将以布隆过滤器算法为研究对象,基于 C# 编程语言开展理论分析与工程实践,系统探讨该算法在企业上网行为管理中的应用范式。
162 8
|
6月前
|
存储 监控 算法
解析公司屏幕监控软件中 C# 字典算法的数据管理效能与优化策略
数字化办公的时代背景下,企业为维护信息安全并提升管理效能,公司屏幕监控软件的应用日益普及。此软件犹如企业网络的 “数字卫士”,持续记录员工电脑屏幕的操作动态。然而,伴随数据量的持续增长,如何高效管理这些监控数据成为关键议题。C# 中的字典(Dictionary)数据结构,以其独特的键值对存储模式和高效的操作性能,为公司屏幕监控软件的数据管理提供了有力支持。下文将深入探究其原理与应用。
116 4
|
7月前
|
机器学习/深度学习 监控 算法
员工上网行为监控软件中基于滑动窗口的C#流量统计算法解析​
在数字化办公环境中,员工上网行为监控软件需要高效处理海量网络请求数据,同时实时识别异常行为(如高频访问非工作网站)。传统的时间序列统计方法因计算复杂度过高,难以满足低延迟需求。本文将介绍一种基于滑动窗口的C#统计算法,通过动态时间窗口管理,实现高效的行为模式分析与流量计数。
181 2
|
7月前
|
域名解析 存储 网络协议
域名解析的终极指南:从基础到进阶,彻底搞懂 DNS 记录
域名解析是网站运行的基础,正确配置DNS记录至关重要。本文从基础到进阶全面解析DNS知识,涵盖A、AAAA、CNAME、MX、TXT、CAA等常见记录类型及其应用场景。通过学习,你将了解DNS的工作原理,掌握如何优化域名配置,确保网站与邮件服务高效运行。无论搭建个人博客还是企业官网,本文都能助你轻松搞定域名解析!
1359 0
|
6月前
|
域名解析 网络协议 网络安全
SSL证书验证全攻略:DNS/HTTP/手动解析怎么选?
SSL证书在网络安全中至关重要,1Panel提供三种验证方式:DNS验证、HTTP验证和手动解析。DNS验证便捷,适合CDN网站;HTTP验证快速,需服务器在线;手动解析灵活,但操作复杂。根据需求选择合适确认方式,定期检查证书状态。
708 2
|
8月前
|
域名解析 存储 缓存
深入学习 DNS 域名解析
在平时工作中相信大家都离不开 DNS 解析,因为 DNS 解析是互联网访问的第一步,无论是使用笔记本浏览器访问网络还是打开手机APP的时候,访问网络资源的第一步必然要经过DNS解析流程。
|
8月前
|
算法 测试技术 C语言
深入理解HTTP/2:nghttp2库源码解析及客户端实现示例
通过解析nghttp2库的源码和实现一个简单的HTTP/2客户端示例,本文详细介绍了HTTP/2的关键特性和nghttp2的核心实现。了解这些内容可以帮助开发者更好地理解HTTP/2协议,提高Web应用的性能和用户体验。对于实际开发中的应用,可以根据需要进一步优化和扩展代码,以满足具体需求。
728 29
|
6月前
|
网络协议 安全 Linux
阿里云服务器国际站dns服务器不可用怎么办?dns可以随便改吗?
阿里云服务器国际站dns服务器不可用怎么办?dns可以随便改吗?
|
8月前
|
监控 算法 安全
基于 C# 的内网行为管理软件入侵检测算法解析
当下数字化办公环境中,内网行为管理软件已成为企业维护网络安全、提高办公效率的关键工具。它宛如一位恪尽职守的网络守护者,持续监控内网中的各类活动,以确保数据安全及网络稳定。在其诸多功能实现的背后,先进的数据结构与算法发挥着至关重要的作用。本文将深入探究一种应用于内网行为管理软件的 C# 算法 —— 基于二叉搜索树的入侵检测算法,并借助具体代码例程予以解析。
131 4

相关产品

  • 云解析DNS
  • 推荐镜像

    更多
  • DNS
  • 下一篇
    开通oss服务