刚才问错了,应该是从IP获得域名才对,怎么做啊
解决方案 »
- C#中Udp通信问题
- windows语言栏只能按住左侧的有点点的区域移动的效果如何实现呢(c#)大侠帮忙啊
- .NET中有什么方法可以debug别的程序?
- 3FA3E97A这个数据如何读取?
- 关于gridview中的数据行绑定事件的问题
- 又有问题求救CSDN的好朋友了. 一个带有webbrowser控件的winform程序,事件.....
- 在线请教
- vs.net2003在vlk 版xp下安装运行时文件时,到最后就不动了?
- C#如何对.net自带的Button的矩形做圆角处理。。本身的太不明显
- WinForm中的DataGrid,为什么时间字段中只显示到日期?
- C# 编写 dll VB6调用
- 怎样在文本框里显示图片
这个是获得主机名,我要的是域名.我做过试验,得不到域名
会得到相应IP:202.108.22.5
现在我的操作就是反过来,输入:202.108.22.5
就应该得到www.baidu.com
{
try
{
/* IPHostEntry ipe = Dns.GetHostEntry(textBox2.Text);
string s = ipe.HostName;*/
string ipe= Dns.GetHostByAddress(IPAddress.Parse(textBox2.Text)).HostName; textBox1.Text = ipe;
}
catch
{
textBox1.Text = "IP不存在,或无法解析";
}
textBox2.SelectAll();
}
这是我的代码
我输入baidu的IP,还是得不到www.baidu.com
Console.Write("Please input your Host name: ");
string strHostName = Console.ReadLine();
Console.WriteLine("You have input: " + strHostName);
string strIP = Dns.GetHostByName(strHostName).AddressList[0].ToString();
Console.WriteLine("IP: " + strIP);
string strHostNameParsed = Dns.GetHostByAddress(IPAddress.Parse(strIP)).HostName;
Console.WriteLine("Host name: " + strHostNameParsed);
Console.Read();
这个返回的是:xd-22-5-a8.bta.net.cn
但是我要的是www.baidu.com
因为我输入www.baidu.com,得到的是这个ip
然后用这个ip反过来查找域名
发现"域名"变成了:xd-22-5-a8.bta.net.cn
麻烦请帮忙..