using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Net; using System.Net.Sockets; using System.IO; using System.Collections.Specialized; namespace myone { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button2_Click(object sender, EventArgs e) { Application.Exit(); } //域名解析 private void button1_Click(object sender, EventArgs e) { if(txtUrl.Text!=string.Empty) { IPHostEntry host = Dns.GetHostEntry(txtUrl.Text);//获取url的主机名 foreach (IPAddress add in host.AddressList)//主机名的ip地址列表地址 { long ip = add.Address;//主机名的ip listBox1.Items.Add(add.ToString());//加地址 255.255.255.255格式 listBox1.Items.Add(ip.ToString());//加ip long 格式 } textName.Text = host.HostName;//主机名(域名代理的情况) textBroad.Text = IPAddress.Broadcast.ToString();//广播地址 } else { MessageBox.Show("请输入网址!", "错误提示"); } } private void textBox2_TextChanged(object sender, EventArgs e) { } private void textBox1_TextChanged(object sender, EventArgs e) { } private void textBox3_TextChanged(object sender, EventArgs e) { } //下载数据 private void button3_Click(object sender, EventArgs e) { WebClient clent = new WebClient();// Stream s = clent.OpenRead(textBox1.Text);//url 必须是http://www.baidu.com http://www.google.com.hk StreamReader reader = new StreamReader(s);//读 richTextBox1.Text = reader.ReadToEnd();//显示 reader.Close(); s.Close(); } //Header private void button4_Click(object sender, EventArgs e) { HttpWebRequest req = (HttpWebRequest)WebRequest.Create(textBox1.Text); HttpWebResponse res = (HttpWebResponse)req.GetResponse(); NameValueCollection headers = res.Headers; foreach(string name in headers) { listBox1.Items.Add(name + "-----" + headers[name]); } } //连接到 Navigate航行,跳转 private void button5_Click(object sender, EventArgs e) { textBox1.Text = "http://www.google.com.hk"; webBrowser1.Navigate(textBox1.Text, false); } } }