以下是引用吹水佬在2023-8-14 09:27:29的发言:
这样看看应该可以理解
* struct in_addr {
* in_addr_t s_addr; //32位无符号整数
* }
DECLARE long strlen IN msvcrt long
DECLARE long inet_addr IN ws2_32 string && in_addr_t inet_addr(const char* cp)
DECLARE long inet_ntoa IN ws2_32 long && char* inet_ntoa(struct in_addr)
ip = "192.168.1.2"
sin_addr = inet_addr(ip)
p = inet_ntoa(sin_addr)
? SYS(2600,p,strlen(p))
? TRANSFORM(BITAND(sin_addr,0xFF)) +"."+;
TRANSFORM(BITAND(BITRSHIFT(sin_addr,8), 0xFF)) +"."+;
TRANSFORM(BITAND(BITRSHIFT(sin_addr,16),0xFF)) +"."+;
TRANSFORM(BITAND(BITRSHIFT(sin_addr,24),0xFF))
这样看看应该可以理解
* struct in_addr {
* in_addr_t s_addr; //32位无符号整数
* }
DECLARE long strlen IN msvcrt long
DECLARE long inet_addr IN ws2_32 string && in_addr_t inet_addr(const char* cp)
DECLARE long inet_ntoa IN ws2_32 long && char* inet_ntoa(struct in_addr)
ip = "192.168.1.2"
sin_addr = inet_addr(ip)
p = inet_ntoa(sin_addr)
? SYS(2600,p,strlen(p))
? TRANSFORM(BITAND(sin_addr,0xFF)) +"."+;
TRANSFORM(BITAND(BITRSHIFT(sin_addr,8), 0xFF)) +"."+;
TRANSFORM(BITAND(BITRSHIFT(sin_addr,16),0xFF)) +"."+;
TRANSFORM(BITAND(BITRSHIFT(sin_addr,24),0xFF))
*!* 返回stSockAddr字符串,再转化为bin和指针地址
lcsin_addr=SUBSTR(stSockAddr,5,4) &&sin_family[2] +sin_port[2] + in_addr sin_addr[4] + sin_zero[8]
lpIP=IIF(1=1,CTOBIN(lcsin_addr, "4RS") , ;
Asc(Substr(lcsin_addr,1,1))*2^0 + Asc(Substr(lcsin_addr,2,1))*2^8+ ;
Asc(Substr(lcsin_addr,3,1))*2^16+ Asc(Substr(lcsin_addr,4,1))*2^24 )
*!* lpIP = inet_addr("192.168.1.2") 返lcsin_addr = BINTOC(inet_addr(@szIP), "4RS");
szIP=SYS(2600,inet_ntoa ( lpIP ) ,16)
szIP4=TRANSFORM(BITAND(BITRSHIFT(lpIP,0),0xFF)) +"."+ TRANSFORM(BITAND(BITRSHIFT(lpIP,8),0xFF)) +;
"."+ TRANSFORM(BITAND(BITRSHIFT(lpIP,16),0xFF)) +"."+ TRANSFORM(BITAND(BITRSHIFT(lpIP,24),0xFF))
? LEFT(szIP, AT(CHR(0), szIP)-1) , szIP4
[此贴子已经被作者于2023-8-14 10:43编辑过]