Socket地址结构

IPv4 socket地址结构通常也称为“网际socket地址结构”,它以sockaddr_in命名,定义在<netinet/in.h>

struct in_addr {
        in_addr_t s_addr; /*32-bit IPv4 address*/
};

struct sockaddr_in {
        uint8_t     sin_len;
        sa_family_t sin_family; /*AF_INET*/
        in_port_t   sin_port;
        struct in_addr sin_addr;
        char sin_zero[8];
};

 通用的socket地址结构如下:

struct sockaddr {
        uint8_t sa_len;
        sa_family_t sa_family; /*address family: AF_XXX value*/
        char sa_data[14]; /*protocol-specific address*/
};

 

  

 

  

posted @ 2022-09-06 17:32  东宫得臣  阅读(135)  评论(0编辑  收藏  举报