windows - how to implement icmpsendecho2 asynchronous with callback example vc -
i have need use icmpsendecho2 api command asynchronously using apcroutine callback routine.
a question have signature apcroutine callback routine need define?
when call icmpsendecho2 third parameter like?
i have 15 proxy request sent. should request icmpsendecho2 once or multiple times.
if need send many icmpsendecho2 requests @ 1 time. how callback apcroutine know icmpsendecho2 call done. guess apccontext parameter comes play?
i can't find example code on msdn or elsewhere demonstrates how use icmpsendecho2 command asynchronously.
int replycame(pvoid param) { char* szaddr = (char*) param; printf("replay came %s......\n", szaddr); return 0; } char* szaddr1 = "172.18.1.1"; char* szaddr2 = "172.18.1.4"; int _tmain(int argc, _tchar* argv[]) { char *senddata = "data buffer"; lpvoid replybuffer; handle icmphandle = icmpcreatefile(); ipaddr addr1 = inet_addr(szaddr1); ipaddr addr2 = inet_addr(szaddr2); replybuffer = (void*) malloc(sizeof(icmp_echo_reply) + sizeof(senddata)); icmpsendecho2(icmphandle, null, (farproc)replycame, szaddr1, addr1, senddata, sizeof(senddata), null, replybuffer, 8*sizeof(replybuffer) + sizeof(icmp_echo_reply), 1000); icmpsendecho2(icmphandle, null, (farproc)replycame, szaddr2, addr2, senddata, sizeof(senddata), null, replybuffer, 8*sizeof(replybuffer) + sizeof(icmp_echo_reply), 1000); sleepex(5000, true); return 0; } do notice if want use replybuffer need parse before icmpparsereplies.
Comments
Post a Comment