IP addresses in C#
在.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#的更多相关文章
- 【leetcode】Restore IP Addresses
Restore IP Addresses Given a string containing only digits, restore it by returning all possible val ...
- 保留ip: Reserved IP addresses
Reserved IP addresses From Wikipedia, the free encyclopedia In the Internet addressing architect ...
- 93. Restore IP Addresses
题目: Given a string containing only digits, restore it by returning all possible valid IP address com ...
- 93.Restore IP Addresses(M)
93.Restore IP Addresses Medium 617237FavoriteShare Given a string containing only digits, restore it ...
- 亚马逊 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 ...
- "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 ...
- 【LeetCode】93. Restore IP Addresses
Restore IP Addresses Given a string containing only digits, restore it by returning all possible val ...
- LeetCode: Restore IP Addresses 解题报告
Restore IP Addresses My Submissions Question Solution Given a string containing only digits, restore ...
- 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 ...
随机推荐
- C# Int转Enum
Int-->Enum (1)可以强制转换将整型转换成枚举类型. 例如:Colors color = (Colors)2 ,那么color即为Colors.Blue (2)利用Enum的静态方法T ...
- python 集合交补
setx = set(["apple", "mango"]) sety = set(["mango", "orange" ...
- [ios]关于ios开发图片尺寸的建议
1.以后的应用程序,都使用AutoLayout, 不要再用绝对定位. 2.使用类似网页的方式来设计界面. 3.设计师好,程序员也好,尽量使用点这个单位进行思考,而不要使用像素.比如,你需要做44 x ...
- table maker's delimma
table maker's delimma是计算机浮点数精度的一个问题. 浮点数的表示方式 计算机能表示的数字都是有理数,所有的有理数都可以归结为下面的模式:1.@@@ × 2#### 其中,@@@ ...
- LeetCode--202--快乐数
问题描述: 编写一个算法来判断一个数是不是“快乐数”. 一个“快乐数”定义为:对于一个正整数,每一次将该数替换为它每个位置上的数字的平方和,然后重复这个过程直到这个数变为 1,也可能是无限循环但始终变 ...
- 12月22日 update_columns,完成第9节。
Update_columns(attributes) //等同于update_column 直接更新database. 使用UPdate SQL 语法. ⚠️ :忽略了validations, Cal ...
- Confluence 6 使用 LDAP 授权连接一个内部目录 - 用户组 Schema 设置
请注意:这部分仅在拷贝用户登录(Copy User on Login)和 同步组成员(Synchronize Group Memberships)被启用后可见. 其他用户组 DN(Additional ...
- 56. Merge Intervals 57. Insert Interval *HARD*
1. Merge Given a collection of intervals, merge all overlapping intervals. For example,Given [1,3],[ ...
- MyBatis:4
转载:http://www.cnblogs.com/xrq730/p/5289638.html 什么是动态SQL MyBatis的一个强大特性之一通常是它的动态SQL能力.如果你有使用JDBC或其他相 ...
- Object是个什么鬼
引言 老人常说,在js中,一切皆对象,那对象又是什么涅,最常用的我们都知道,对象有方法和属性.由一些键值对构成的集合,然后随便用个大括号括起来就形成了一个对象.看起来蛮简单的,但是真是这么简单么,当我 ...