in_addr是一個結構體,可以用來表示一個32位的IPv4地址。
基本介紹
- 外文名:in_addr
- 結構體頭檔案:#include <arpa/inet.h>
- 結構體樣式:struct in_addr {
- 代碼中的套用:server.sin_addr=
結構體頭檔案
結構體樣式
struct in_addr { in_addr_t s_addr;};
IP結構體的使用
struct in_addr{ union { struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b; //An IPv4 address formatted as four u_chars. struct { u_short s_w1,s_w2; } S_un_w; //An IPv4 address formatted as two u_shorts u_long S_addr;//An IPv4 address formatted as a u_long } S_un;#define s_addr S_un.S_addr};