- if dnsserverid >= 0 then begin\r
- reportlag(dnsserverid,trunc((unixtimefloat-startts)*1000));\r
- dnsserverid := -1;\r
- end;\r
-{ writeln('received reply');}\r
- fillchar(state.recvpacket,sizeof(state.recvpacket),0);\r
- state.recvpacketlen := twsocket(sender).Receive(@state.recvpacket, SizeOf(state.recvpacket));\r
- state.parsepacket := true;\r
- asyncprocess;\r
+ socketno := tlsocket(sender).tag;\r
+ //writeln('got a reply on socket number ',socketno);\r
+ fillchar(states[socketno].recvpacket,sizeof(states[socketno].recvpacket),0);\r
+\r
+ SrcLen := SizeOf(Src);\r
+ states[socketno].recvpacketlen := twsocket(sender).ReceiveFrom(@(states[socketno].recvpacket), SizeOf(states[socketno].recvpacket), Src, SrcLen);\r
+\r
+ fromip := inaddrvtobinip(Src);\r
+ fromport := inttostr(htons(src.InAddr.port));\r
+\r
+ if ((not comparebinip(fromip,destinations[socketno])) or (fromport <> port)) then begin\r
+ // writeln('dnsasync received from wrong IP:port ',ipbintostr(fromip),'#',fromport,', expected ',ipbintostr(destinations[socketno]),'#',port);\r
+ exit;\r
+ end;\r
+\r
+ states[socketno].parsepacket := true;\r
+ if states[socketno].resultaction <> action_done then begin\r
+ //we ignore packets that come after we are done\r
+ if dnsserverids[socketno] >= 0 then begin\r
+ reportlag(dnsserverids[socketno],trunc((unixtimefloat-startts)*1000000));\r
+ dnsserverids[socketno] := -1;\r
+ end;\r
+ { writeln('received reply');}\r
+\r
+ asyncprocess(socketno);\r
+ //writeln('processed it');\r
+ end else begin\r
+ //writeln('ignored it because request is done');\r
+ end;\r