ip nat inside source static,IP addresses in C#

 2023-10-08 阅读 25 评论 0

摘要:在.Net網絡庫里面最大的優點就是IP地址和端口被成對處理,相比于UNIX中用的方法真是一個巨大的令人歡迎的進步。.NET定義了兩個類來處理關于IP地址的問題。 One of the biggest advantages you will notice in the .NET network library is the way IP address/port pai

在.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()函數經常用來構造該類。

ip nat inside source static,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.

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/4/132508.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息