【HSP3】Ping送信

hspping.dll (http://www.binzume.net/software/forhsp.html) がありますが、モジュール版ということで。微妙に互換性ないです。

hspping.dll (http://www.binzume.net/software/forhsp.html) がありますが、モジュール版ということで。微妙に互換性ないです。

  • hk1v
  • 2013/5/2 17:03
  • タグ:
  • タグはありません
//
#module
#uselib "ws2_32.dll"
#cfunc WSAStartup "WSAStartup" int, sptr
#cfunc inet_addr "inet_addr" str
#cfunc gethostbyname "gethostbyname" str
#uselib "icmp.dll"
#cfunc IcmpCreateFile "IcmpCreateFile"
#cfunc IcmpSendEcho "IcmpSendEcho" int, int, str, int, int, var, int, int
#func IcmpCloseHandle "IcmpCloseHandle" int
#deffunc InitPing
sdim WSAData, 400
if WSAStartup(0x0101, varptr(WSAData)) != 0{
return -1
}
SetPingSendData "ICMP SEND DATA"
return 0
#deffunc SetPingSendData str data
send_data = data
recv_size = 28 + strlen(send_data) + 1
return 0
#defcfunc GetAddr str addr
int_addr = 0
int_addr = inet_addr(addr)
if int_addr != 0{
ret = gethostbyname(addr)
if ret != 0{
dupptr tmp, ret + 12, 4
dupptr ret, tmp, 4
dupptr int_addr, ret, 4
}else{
return 0
}
}
return int_addr
#deffunc Ping var ms, int _int_addr, int timeout
dim recv_data, (recv_size / 4) + 1
hIcmp = IcmpCreateFile()
ret = IcmpSendEcho(hIcmp, _int_addr, send_data, strlen(send_data), 0, recv_data, recv_size, timeout)
if (ret != 0) {
ms = recv_data.2
}else{
return -1
}
IcmpCloseHandle hIcmp
return 0
#global
// IPv6
//
InitPing
// xn--n8j3azcmra9bymod5gnkxgnr.com -> .com
ping_addr_list.0 = "127.0.0.1", "www.google.co.jp", "www.yahoo.co.jp"
ping_addr_list.3 = "www.microsoft.com", "329.932.129.848", "::1"
ping_addr_list.6 = "xn--n8j3azcmra9bymod5gnkxgnr.com"
repeat length(ping_addr_list)
mes ping_addr_list(cnt) + " ping ..."
// ping
Ping time, GetAddr(ping_addr_list(cnt)), 1000 // 1
if stat != -1{
mes "-> " + time + " ms"
}else{
mes "-> ping "
}
mes "------------------------------------------"
loop
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX