如何将u_int32类型转换为字符串的ip地址

4409阅读 0评论2009-12-16 zyq840112
分类:

I:inet_ntoa

举例:char *ipaddr=NULL;
     char   addr[20];
     in_addr  inaddr;
     inaddr.s_addr=***;
     ipaddr=inet_ntoa(inaddr);
     strcpy(addr,ipaddr);

II:
IntIP=...   //int ip address

Byte A = Byte(this-> IntIP   >>   24);
Byte B = Byte(this-> IntIP   >>   16);
Byte C = Byte(this-> IntIP   >>   8);
Byte D = Byte(this-> IntIP);

Text1 = IntToStr(A);
Text2 = IntToStr(B);
Text3 = IntToStr(C);
Text4 = IntToStr(D);
上一篇:hostent结构体[转]
下一篇: Linux内存映射: mmap[转]