在.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. NS3 Ptr<Rocket> 与 TcpRocket 的一个小问题

    前因:ns3网络仿真 实验进行到很关键的一步,我尝试进行了代码的编写(还没有添加Traceback的函数),如下: #include "ns3/core-module.h" #in ...

  2. kaggle CTR预估

    参考涛哥之前做过的CTR预估project,学习下CTR预估的相关知识:http://blog.csdn.net/hero_fantao/article/category/6877765 目标:本周末 ...

  3. C++中的也能使用正则表达式----转载

    转自:https://www.cnblogs.com/ittinybird/p/4853532.html, 以作笔记. 正则表达式Regex(regular expression)是一种强大的描述字符 ...

  4. go下载安装

    https://studygolang.com/dl 一直下一步即可.

  5. ros python 重置位置

    #!/usr/bin/env python import rospy import math import sys import commands import yaml from tf import ...

  6. MongoDB(课时3 MongoDB基本操作)

    3.3 MongoDB的基本操作 在MongoDB数据库里面存在数据库的概念,但没有模式(所有的信息都是按照文档保存的),保存数据的结构是BSON结构,只不过在进行一些数据处理的时候才会使用到Mong ...

  7. iOS Socket编程-C语言版(UDP)

    . UDP Socket编程 先讲一讲UDP编程,因为比TCP要简单多了.首先,我们需要明白UDP是用户数据报协议,英文名为User Datagram Protocol,它是面向无连接的. 注意:So ...

  8. Android 实现文件上传功能(upload)

    文 件上传在B/S应用中是一种十分常见的功能,那么在Android平台下是否可以实现像B/S那样的文件上传功能呢?答案是肯定的.下面是一个模拟网站程 序上传文件的例子.这里只写出了Android部分的 ...

  9. (转帖整理)Linux下的Autoconf和AutoMake(理论篇) 1

    在搜索网上资料过程中,这是感觉最简洁有效的一篇文章,特进行转帖记录,并根据情况对部分内容进行了修改.原帖传送门:Linux下的Autoconf和AutoMake 1.工具安装在开始使用autoconf ...

  10. WPF 的 数据源属性 和 数据源

    (一)数据源(数据对象)属性 :path 或  path的值(path=VM.Property或M.Property),通常具有通知功能(特例除外). (二)path不能孤立而存在,它一定具有所归属的 ...