获得主机域名及其IP和Port端口
来源:互联网 发布:网络热词大全2017 编辑:程序博客网 时间:2024/05/18 02:58
主程序代码:
// 由主机域名获得其IP地址
protected void btnShowLocal_Click(object sender, EventArgs e)
{
txtaShowAnswer.Value = "";
string strShowAnwser = string.Empty;
string strHostName = Dns.GetHostName(); //获取本地主机名
strShowAnwser = "The local host's name is: " + strHostName + "/n";
IPHostEntry ipHost = Dns.GetHostEntry(strHostName); //将主机名解析成IPHostEntry实例
foreach (IPAddress ip in ipHost.AddressList) //将主机名(域名)对应的IP全部解析出来
strShowAnwser += "The local host's IP is: " + ip.ToString() + "/n";
IPAddress LocalIP = IPAddress.Parse("127.0.0.1"); //将字符串实例成IP地址
IPEndPoint ipEP = new IPEndPoint(LocalIP, 80); //将网络端点表示成IP地址和端口号
strShowAnwser += "The IPEndPoint is: " + ipEP.ToString() + "/n";
strShowAnwser += "The Address is: " + ipEP.Address + "/n";
strShowAnwser += "The Port is: " + ipEP.Port + "/n";
strShowAnwser += "The AddressFamily is: " + ipEP.AddressFamily + "/n";
strShowAnwser += "The Max port number is: " + IPEndPoint.MaxPort + "/n";
strShowAnwser += "The Min port number is: " + IPEndPoint.MinPort + "/n";
txtaShowAnswer.Value = strShowAnwser;
}
运行结果:
The local host's name is: Young
The local host's IP is: ::1
The local host's IP is: 210.77.29.132
The IPEndPoint is: 127.0.0.1:80
The Address is: 127.0.0.1
The Port is: 80
The AddressFamily is: InterNetwork
The Max port number is: 65535
The Min port number is: 0
- 获得主机域名及其IP和Port端口
- 通过域名获得主机ip
- 根据主机域名获得主机IP
- 获得主机域名(DNS)
- 获得主机的IP和主机名
- 域名?主机?IP?DNS?
- 二级域名共享主机IP和端口
- Linux下获得主机与域名-gethostbyname和gethostbyaddr
- Linux下获得主机与域名-gethostbyname和gethostbyaddr
- 通过域名获得IP
- 通过域名获得IP
- 获得本地主机IP
- 获得主机IP
- 获得主机IP
- Java-通过IP地址获得域名和主机名
- 域名中ip和端口的问题,java通过域名获取ip
- Delphi 实现获得主机IP地址和主机名
- 根据域名获取ip地址、端口、服务器类型和标题
- 本文详细介绍从Undo, Redo, DataFile看Oracle中的事务过程
- Distributed Key-Value Database
- 手把手教你玩转SOCKET模型之重叠I/O篇(上)
- Java面向对象编程-6.3 方法覆盖(Override)
- windows 操作系统介绍
- 获得主机域名及其IP和Port端口
- 开启Telnet服务
- [资料文本] Matlab中图像的邻域与块运算(blkproc)
- 数组的引用
- 一个PRM系统实施的经验与教训
- 迅速迭代,越变越美
- 豆瓣beansdb key-value数据库(1)
- 我2010怎么办呢?!
- 员工缺乏责任心的四大原因