资源简介
获得主机域名及其IP和Port端口(初步入门)

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender EventArgs e)
{
txtaShowAnswer.Value = ““;
}
// 由主机域名获得其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;
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1074 2010-01-24 21:13 Ip2Url\Default.aspx
文件 1678 2010-01-24 21:14 Ip2Url\Default.aspx.cs
文件 1489 2010-01-24 16:45 Ip2Url\Ip2Url.sln
..A..H. 8704 2010-01-24 21:18 Ip2Url\Ip2Url.suo
文件 8682 2010-01-24 16:10 Ip2Url\web.config
目录 0 2010-01-24 16:10 Ip2Url\App_Data
目录 0 2010-01-24 21:14 Ip2Url
----------- --------- ---------- ----- ----
21627 7
- 上一篇:基于C/S模式的学生信息管理系统
- 下一篇:小型无线局域网系统设计
相关资源
- Modbus协议官方文档中、英文全
- ModelGoon-4.4.1-site.zip
- 信号奇异点Lipschitz指数计算
- vspd7.2.308.zip
- pthreads-w32-2-9-1-release.zip
- Navicat Premium 15汉化包.zip55438
- 登录注册界面.zip48872
- 电信中兴光猫超密获取工具使用方法
-
Actionsc
ript 1.0实现能跟随鼠标运动的 - IAR-Keygen-2019+附使用教程.zip
-
st
yles 引文样式语言( CSL ) 引文样 - Reparatory Effects of Nicotine on NMDA Recepto
- Apolipoprotein E4 Impairs in vivo Hippocampal
- flash as3 多点触控-缩放-旋转-滑动.zi
- Quartus II 15.0中仿真Altera三速以太网I
- Quartus II 15.0中仿真Altera三速以太网I
-
imx6qSBP的jli
nk初始化脚本 - IMX385驱动代码.zip
- sony_imx385.zip
- 数字华容道
- jstl-api-1.2和jstl-impl-1.2
- 基于MIPS指令集的32位CPU设计与Verilog语
- 基于MVC模式的会员管理系统
- IP地址转换整形工具
- 直观端口查看器,详细显示可疑进程
- 佳能IP2780清零
- SIP电话实例
- 一个简单的verilog编写的DMA IP CORE,和
- ipv6网络抓包程序
- 超市收银系统eclipse access大学课程设计
评论
共有 条评论