回复 8楼 吹水佬
struct sockaddr {
ushort
sa_family;
char
sa_data[14];
};
struct sockaddr_in {
short
sin_family;
u_short sin_port;
struct
in_addr sin_addr;
char
sin_zero[8];
};
DECLARE LONG inet_ntoa IN "Ws2_32" LONG
SYS(2600,inet_ntoa (CTOBIN(SUBSTR(stSockAddr,5,4), "4RS") ) ,16)
LEFT(szIP, AT(0h00, szIP)-1)
---------------------------------------------------------------------
* 取IP地址
* SYS(2600, lpIP地址, 4)返回 in_addr 结构指针
nIP = CTOBIN(SYS(2600, lpIP地址, 4), "4RS")
* 转换成“.”分隔字串(xxx.xxx.xxx.xxx)
* inet_ntoa()返回IP字符串指针
szIP = SYS(2600, inet_ntoa(nIP), 16)
*!*
?sz域名,szIP
szIP = LEFT(szIP, AT(0h00, szIP)-1)
nlen = ALEN(aIP) + 1
DIMENSION aIP(nlen)
aIP[nlen] = szIP
还是用如下取法
Substr(lpBuffer,lnOffs,4))
Asc(Substr(lcBuffer,1,1))+;
Asc(Substr(lcBuffer,2,1))*256+;
Asc(Substr(lcBuffer,3,1))*65536+;
Asc(Substr(lcBuffer,4,1))*16777216
[此贴子已经被作者于2023-8-14 09:05编辑过]