在.Net网络库里面最大的优点就是IP地址和端口被成对处理,相比于UNIX中用的方法真是一个巨大的令人欢迎的进步。.NET定义了两个类来处理关于IP地址的问题。

One of the biggest advantages you will notice in the .NET network library is the way IP address/port pairs are handled. It is a fairly straightforward process that presents a welcome improvement over the old, confusing UNIX way. .NET defines two classes in the System.Net namespace to handle various types of IP address information:

  • IPAddress
  • IPEndPoint
IPAddress

一个IP地址对象用来表示一个单一的IP地址,其值同时也可以应用在许多不同的方法里面。

An IPAddress object is used to represent a single IP address. This value is then used in various socket methods to represent the IP address. The default constructor for IPAddress is as follows:

public IPAddress(long address)

实际上,默认的构造函数几乎是用不到的,因为在该类里面许多的函数可以用来构造并操作IP地址对象。其中Parser()函数经常用来构造该类。

The default constructor takes a long value and converts it to an IPAddress value. In practice, the default is almost never used. Instead, several methods in theIPAddress class can be used to create and manipulate IP addresses. The Parse() method is often used to create IPAddress instances:

IPAddress newaddress = IPAddress.Parse("192.168.1.1");
IPEndPoint

.NET框架用IPEndPoint 对象来表示一个特定的IP地址和端口的组合,应用该对象的场景多是在讲socket绑定到本地地址或者将socket绑定到非本地地址。

The .NET Framework uses the IPEndPoint object to represent a specific IP address/port combination. An IPEndPoint object is used when binding sockets to local addresses, or when connecting sockets to remote addresses.

IP addresses in C#的更多相关文章

  1. 【leetcode】Restore IP Addresses

    Restore IP Addresses Given a string containing only digits, restore it by returning all possible val ...

  2. 保留ip: Reserved IP addresses

    Reserved IP addresses From Wikipedia, the free encyclopedia     In the Internet addressing architect ...

  3. 93. Restore IP Addresses

    题目: Given a string containing only digits, restore it by returning all possible valid IP address com ...

  4. 93.Restore IP Addresses(M)

    93.Restore IP Addresses Medium 617237FavoriteShare Given a string containing only digits, restore it ...

  5. 亚马逊 AWS ip反向解析:Configurable Reverse DNS for Amazon EC2’s Elastic IP Addresses

    I’d like to call your attention to a new feature that we rolled out earlier this month. You can now ...

  6. "cni0" already has an IP address different from 10.244.2.1/24。 Error while adding to cni network: failed to allocate for range 0: no IP addresses available in range set: 10.244.2.1-10.244.2.254

    "cni0" already has an IP address different from 10.244.2.1/24. Error while adding to cni n ...

  7. 【LeetCode】93. Restore IP Addresses

    Restore IP Addresses Given a string containing only digits, restore it by returning all possible val ...

  8. LeetCode: Restore IP Addresses 解题报告

    Restore IP Addresses My Submissions Question Solution Given a string containing only digits, restore ...

  9. LeetCode解题报告—— Reverse Linked List II & Restore IP Addresses & Unique Binary Search Trees II

    1. Reverse Linked List II Reverse a linked list from position m to n. Do it in-place and in one-pass ...

随机推荐

  1. Ubuntu上 配置Eclipse:安装CDT

    在最新的 Ubuntu Kylin 16.04 中安装了eclipse,在纠结了很久的网络问题之后,开始了eclipse的配置以便在上面运行ns3. 在官方网站上安装完 eclipse LUNA 之后 ...

  2. 获取CheckBox的值

    前台获取 function chkCheckBox() { var code_arr = new Array(); //定义一数组 $('.C_B').each(function () { if ($ ...

  3. hdu 6020 MG loves apple 恶心模拟

    题目链接:点击传送 MG loves apple Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 262144/262144 K (Ja ...

  4. 转载:oracle 11g ADG实施手册(亲测,已成功部署多次)

    https://www.cnblogs.com/yhfssp/p/7815078.html 一:实验环境介绍 虚拟机系统: RHEL Linux 6.4(64位) 数据库版本: Oracle 11gR ...

  5. MongoDB(课时10 数组)

    3.4.2.5 数组查询 MongoDB里面支持数组保存,一旦支持数组保存,就需要对于数组的数据进行匹配. 范例:插入一部分数组内容 课程是数组的形式(截图时少截一条信息) 此时数据包含数组内容,而后 ...

  6. 爱阅app --- 答复功能改进建议

    共有四组评论,接下来一一答复. 第一组: 希望增加的功能: 1.希望能够继续完善书签功能,增加逐条删除书签功能. 2.能够在爱阅内部打开APP中提供的网址,用户选择一款阅读APP,当然不想每看一本新的 ...

  7. Java 集合-Set接口和三个子类实现

    2017-10-31 19:20:45 Set 一个不包含重复元素的 collection.无序且唯一. HashSet LinkedHashSet TreeSet HashSet是使用哈希表(has ...

  8. ASP.NET调用dos命令获取交换机流量

    protected void btn_Cisco_Click(object sender, EventArgs e) { try { string ip = txt_ip.Value; string ...

  9. java生产条形码

      一.通过JBarcode(此种方式可以隐藏掉条形码下面的字符串)   1.下载jar包  jbarcode-0.2.8.jar  目前maven中央仓库并没有jbarcode的坐标  如果是mav ...

  10. ubuntu安装环境软件全文档

    1,安装apace2: sudo apt-get install apache2 2谷歌浏览器的安装:sudo apt-get install  chromium-browser-dbg 3,国际版Q ...