zoukankan      html  css  js  c++  java
  • 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.

  • 相关阅读:
    redux的使用流程
    react类型检查
    将逻辑运算字符串转化为逻辑运算进行运算
    SQL 行列互换 天高地厚
    【转载】linux的IO调度算法和回写机制 天高地厚
    查询昨天的数据 天高地厚
    摘:DBA案例CPU占用100%的问题 天高地厚
    ASP.net HTTP/HTTPS自动切换 天高地厚
    网络连接和初始HTTP请求 天高地厚
    C++内存对象大会战 . 天高地厚
  • 原文地址:https://www.cnblogs.com/yuhuameng/p/3578574.html
Copyright © 2011-2022 走看看