X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/2579cad7a973072619a7fc17ff6af9cc75264972..66fc75f9dc1f2fe4e0f478fb76a14492f4ab1b82:/dnssync.pas?ds=inline diff --git a/dnssync.pas b/dnssync.pas index 79ace01..f6b0281 100644 --- a/dnssync.pas +++ b/dnssync.pas @@ -132,7 +132,7 @@ procedure setupsocket; var inAddrtemp : TInetSockAddrV; biniptemp:tbinip; - a,retrycount:integer; + a,retrycount,porttemp:integer; bindresult:boolean; begin biniptemp := getcurrentsystemnameserverbin(id); @@ -144,7 +144,13 @@ begin for a := 0 to numsockused-1 do begin retrycount := 5; repeat - makeinaddrv(biniptemp,inttostr( 1024 + randominteger(65536 - 1024) ),inaddrtemp); + if (retrycount <= 1) then begin + porttemp := 0; //for the last attempt let the OS decide + end else begin + porttemp := 1024 + randominteger(65536 - 1024); + end; + + makeinaddrv(biniptemp,inttostr( porttemp ),inaddrtemp); fd[a] := Socket(biniptemp.family,SOCK_DGRAM,0); bindresult := {$ifdef win32}Not{$endif} Bind(fd[a],inAddrtemp,inaddrsize(inaddrtemp));