zoukankan      html  css  js  c++  java
  • Host Address Data Type

    Host Address Data Type
    IPv4 Internet host addresses are represented in some contexts as integers (type uint32_t).
    In other contexts, the integer is packaged inside a structure of type struct in_addr. It
    would be better if the usage were made consistent, but it is not hard to extract the integer
    from the structure or put the integer into a structure.
    You will find older code that uses unsigned long int for IPv4 Internet host addresses
    instead of uint32_t or struct in_addr. Historically unsigned long int was a 32-bit number
    but with 64-bit machines this has changed. Using unsigned long int might break the
    code if it is used on machines where this type doesn’t have 32 bits. uint32_t is specified
    by Unix98 and guaranteed to have 32 bits.
    IPv6 Internet host addresses have 128 bits and are packaged inside a structure of type
    struct in6_addr.
    The following basic definitions for Internet addresses are declared in the header file
    ‘netinet/in.h’:
    struct in_addr [Data Type]
    This data type is used in certain contexts to contain an IPv4 Internet host address.
    It has just one field, named s_addr, which records the host address number as an
    uint32_t.
    uint32_t INADDR_LOOPBACK [Macro]
    You can use this constant to stand for “the address of this machine,” instead of finding
    its actual address. It is the IPv4 Internet address ‘127.0.0.1’, which is usually called
    ‘localhost’. This special constant saves you the trouble of looking up the address of
    your own machine. Also, the system usually implements INADDR_LOOPBACK specially,
    avoiding any network traffic for the case of one machine talking to itself.
    Chapter 16: Sockets 400
    uint32_t INADDR_ANY [Macro]
    You can use this constant to stand for “any incoming address” when binding to an
    address
    . This is the usual address to give in the sin_addr member of struct sockaddr_in when you
    want to accept Internet connections.
    uint32_t INADDR_BROADCAST [Macro]
    This constant is the address you use to send a broadcast message.
    uint32_t INADDR_NONE [Macro]
    This constant is returned by some functions to indicate an error.
    struct in6_addr [Data Type]
    This data type is used to store an IPv6 address. It stores 128 bits of data, which can
    be accessed (via a union) in a variety of ways.
    struct in6_addr in6addr_loopback [Constant]
    This constant is the IPv6 address ‘::1’, the loopback address. See above for a description
    of what this means. The macro IN6ADDR_LOOPBACK_INIT is provided to
    allow you to initialize your own variables to this value.
    struct in6_addr in6addr_any [Constant]
    This constant is the IPv6 address ‘::’, the unspecified address. See above for a
    description of what this means. The macro IN6ADDR_ANY_INIT is provided to allow
    you to initialize your own variables to this value.

  • 相关阅读:
    阿里容器简介
    docker学习笔记(总纲)
    Apache利用mod_limitipconn模块限制客户端多线程下载
    Android从assets目录下读取文件相关
    android 指纹识别
    App前后台判断
    Error:Failed to create directory 'C:UsersAdministrator.gradlecaches2.8scriptsijinit7_5jx13p26
    com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files
    重复导包:Error:Execution failed for task ':countrynumberlibrary:mergeDebugResources'. > Some file crunching failed, see logs for details
    支付宝集成
  • 原文地址:https://www.cnblogs.com/haimingwey/p/2474738.html
Copyright © 2011-2022 走看看