in_addr结构:The in_addr structure represents an IPv4 Internet address.
typedef struct in_addr {
union {
struct {
u_char s_b1,s_b2,s_b3,s_b4;
} S_un_b;
struct {
u_short s_w1,s_w2;
} S_un_w;
u_long S_addr;
} S_un;
} IN_ADDR,
*PIN_ADDR,
FAR *LPIN_ADDR;
参数解释:
S_un_b An IPv4 address formatted as four u_chars.
S_un_w An IPv4 address formatted as two u_shorts.
S_addr An IPv4 address formatted as a u_long.(注意:如果是字符串类型的ip地址可以通过inet_addr()
函数转变成u_long类型的ip地址,如果想从S_addr中得到字符串类型的ip地址可以通过inet_ntoa()
函数)