socket中ip地址保存方式

nginx中uip = ((struct sockaddr_in *) r->connection->sockaddr)->sin_addr.s_addr取得unsinged int ip地址。

hip = htons(uip)

ip = sprintf("%d.%d.%d.%d", hip>>0x24, (hip >> 0x16) & 0xff, (hip >> 0x08) & 0xff, hip & 0xff)


你可能感兴趣的:(socket中ip地址保存方式)