zoukankan      html  css  js  c++  java
  • socket 主机地址相关的函数

     

    #include <arpa/inet.h>
    int inet_aton (const char *name, struct in_addr *addr)

      将ipv4地址从数字点的形式转化为二进制数据,存储在struct in_addr中。如果给的地址无效,返回0

    uint32_t inet_addr (const char *name)

      和inet_aton一样,将存储在字符串里的数字点形式的IPv4地址转化为二进制数据。输入地址无效会返回INADDR_NONE,实际值为255.255.255.255

    uint32_t inet_network (const char *name)

      将数字点形式的Ipv4地址按主机字节顺序转化使用网络地址????

    char * inet_ntoa (struct in_addr addr)

    和上面相反:struct in_addr 到数字点形式的IPv4地址。 

    struct in_addr inet_makeaddr (uint32_t net, uint32_t local)
    //使用网络号和主机号构成IPv4地址。对无类型的地址不起作用。
     uint32_t inet_netof (struct in_addr addr)
    //返回IPv4地址的网络号
    int inet_pton (int af, const char *cp, void *buf)
    //将Internet 地址(IPv4或者IPv6)从可表示(textual) 转换到网络上的二进制格式
    //af 指address_family,值必须是AF_INET或AF_INET6。
    //cp 指向输入字符串,buf为输出。调者必须保证buf足够大。大小应该为struct in_addr 或者struct in6_addr
    const char * inet_ntop (int af, const void *cp, char *buf, socklen_t len)
    //和上一个函数功能相反。socklen_t len为buffer的长度。两个返回值出口:char *buf和return返回的buf的地址。
  • 相关阅读:
    leetcode--Interleaving String
    SR4000自带软件修改(二)
    修改SR4000自带软件,支持opencv
    获取当前进程的寄存器内容
    sr4000自带API和opencv结合获取图像
    远程进程注入
    【转+心得】WinDbg+VM9双机调试无法连接解决方案
    boost库的使用(一)
    SR4K的API使用(libMesaSR.dll)
    java含多个包的命令行下执行
  • 原文地址:https://www.cnblogs.com/san-fu-su/p/5752672.html
Copyright © 2011-2022 走看看