IP addresses in C#
2014-03-03 16:15
309 查看
在.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
IPAddress
一个IP地址对象用来表示一个单一的IP地址,其值同时也可以应用在许多不同的方法里面。
An
实际上,默认的构造函数几乎是用不到的,因为在该类里面许多的函数可以用来构造并操作IP地址对象。其中Parser()函数经常用来构造该类。
The default constructor takes a
IPEndPoint
.NET框架用
The .NET Framework uses the
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.Netnamespace to handle various types of IP address information:
IPAddress
IPEndPoint
IPAddress
一个IP地址对象用来表示一个单一的IP地址,其值同时也可以应用在许多不同的方法里面。
An
IPAddressobject 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
IPAddressis as follows:
public IPAddress(long address)
实际上,默认的构造函数几乎是用不到的,因为在该类里面许多的函数可以用来构造并操作IP地址对象。其中Parser()函数经常用来构造该类。
The default constructor takes a
longvalue and converts it to an
IPAddressvalue. In practice, the default is almost never used. Instead, several methods in the
IPAddressclass can be used to create and manipulate IP addresses. The
Parse()method is often used to create
IPAddressinstances:
IPAddress newaddress = IPAddress.Parse("192.168.1.1");
IPEndPoint
.NET框架用
IPEndPoint对象来表示一个特定的IP地址和端口的组合,应用该对象的场景多是在讲socket绑定到本地地址或者将socket绑定到非本地地址。
The .NET Framework uses the
IPEndPointobject to represent a specific IP address/port combination. An
IPEndPointobject is used when binding sockets to local addresses, or when connecting sockets to remote addresses.
相关文章推荐
- How to scan whole Internet 3.7 billion IP addresses in few minutes?
- LeetCode Online Judge 题目C# 练习 - Restore IP Addresses
- TCP/IP Sockets in C#: Practical Guide for Programmers
- Get a list of network interfaces and their IP addresses in C
- Deny IP address in IIS via C#
- IP Watchdog: Simple Windows Service Written in C#
- Simple TCP/IP Echo Server & Client Application in C#
- leetcode -day29 Binary Tree Inorder Traversal & Restore IP Addresses
- c# pingreply ipaddress in win vista+
- 【Lintcode】Restore IP Addresses, Number of Airplanes in the Sky
- Convert IP addresses from a dots-and-number string to a struct in_addr and back
- leetcode -day29 Binary Tree Inorder Traversal & Restore IP Addresses
- c# Dns.GetHostAddresses获取ip为乱码
- Find Top Source IP Addresses in Distributed Systems
- c# Dns.GetHostAddresses获取ip为乱码
- TCP/IP Sockets in C#: Practical Guide for Programmers
- Configuring Floating IP addresses for Networking in OpenStack Public and Private Clouds
- C# .net 如何根据访问者IP获取所在地区
- C#获取本机所有IP地址(包括局域网和本机外网IP)