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.

  • 相关阅读:
    Gdb等几则笔记
    让GtkTextView支持undo/redo操作
    让基于DirectFB的Mozilla支持透明图
    在minimo中用方向键切换焦点
    Marvelllinux研究—dma.c源代码分析
    “垃圾”文章为何能上首页
    用xoops建立自己的开源网站
    R语言中sample函数
    R语言中text函数
    R语言绘图去除外围框线、坐标轴标线
  • 原文地址:https://www.cnblogs.com/yuhuameng/p/3578574.html
Copyright © 2011-2022 走看看