X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/f3321a0eafbeda0e8ebfb420974d391d7904ed44..2579cad7a973072619a7fc17ff6af9cc75264972:/dnssync.pas?ds=sidebyside diff --git a/dnssync.pas b/dnssync.pas index d037a68..79ace01 100644 --- a/dnssync.pas +++ b/dnssync.pas @@ -71,6 +71,7 @@ implementation {$i unixstuff.inc} +type tdnsstatearr=array[0..numsock-1] of tdnsstate; {$ifdef syncdnscore} @@ -98,9 +99,6 @@ begin {$endif} end; - -type tdnsstatearr=array[0..numsock-1] of tdnsstate; - procedure resolveloop(timeout:integer;var state:tdnsstatearr;numsockused:integer); var selectresult : integer; @@ -134,7 +132,8 @@ procedure setupsocket; var inAddrtemp : TInetSockAddrV; biniptemp:tbinip; - a:integer; + a,retrycount:integer; + bindresult:boolean; begin biniptemp := getcurrentsystemnameserverbin(id); //must get the DNS server here so we know to init v4 or v6 @@ -143,11 +142,16 @@ begin for a := 0 to numsockused-1 do begin - makeinaddrv(biniptemp,inttostr( 1024 + randominteger(65536 - 1024) ),inaddrtemp); + retrycount := 5; + repeat + makeinaddrv(biniptemp,inttostr( 1024 + randominteger(65536 - 1024) ),inaddrtemp); - fd[a] := Socket(biniptemp.family,SOCK_DGRAM,0); + fd[a] := Socket(biniptemp.family,SOCK_DGRAM,0); + bindresult := {$ifdef win32}Not{$endif} Bind(fd[a],inAddrtemp,inaddrsize(inaddrtemp)); + dec(retrycount); + until (retrycount <= 0) or (bindresult); - If {$ifndef win32}Not{$endif} Bind(fd[a],inAddrtemp,inaddrsize(inaddrtemp)) Then begin + If (not bindresult) Then begin {$ifdef win32} raise Exception.create('unable to bind '+inttostr(WSAGetLastError)); {$else}