lcore.org gitweb
/
lcore.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
dnssync lookup retry to listen in case port is in use
[lcore.git]
/
dnssync.pas
diff --git
a/dnssync.pas
b/dnssync.pas
index 60af58082e36a7d075a67fe41d5009683e4f9873..79ace01ca056e4d63312b7a2e807a307f539fb33 100644
(file)
--- a/
dnssync.pas
+++ b/
dnssync.pas
@@
-132,7
+132,8
@@
procedure setupsocket;
var
\r
inAddrtemp : TInetSockAddrV;
\r
biniptemp:tbinip;
\r
var
\r
inAddrtemp : TInetSockAddrV;
\r
biniptemp:tbinip;
\r
- a:integer;
\r
+ a,retrycount:integer;
\r
+ bindresult:boolean;
\r
begin
\r
biniptemp := getcurrentsystemnameserverbin(id);
\r
//must get the DNS server here so we know to init v4 or v6
\r
begin
\r
biniptemp := getcurrentsystemnameserverbin(id);
\r
//must get the DNS server here so we know to init v4 or v6
\r
@@
-141,11
+142,16
@@
begin
\r
\r
for a := 0 to numsockused-1 do begin
\r
\r
\r
for a := 0 to numsockused-1 do begin
\r
- makeinaddrv(biniptemp,inttostr( 1024 + randominteger(65536 - 1024) ),inaddrtemp);
\r
+ retrycount := 5;
\r
+ repeat
\r
+ makeinaddrv(biniptemp,inttostr( 1024 + randominteger(65536 - 1024) ),inaddrtemp);
\r
\r
\r
- fd[a] := Socket(biniptemp.family,SOCK_DGRAM,0);
\r
+ fd[a] := Socket(biniptemp.family,SOCK_DGRAM,0);
\r
+ bindresult := {$ifdef win32}Not{$endif} Bind(fd[a],inAddrtemp,inaddrsize(inaddrtemp));
\r
+ dec(retrycount);
\r
+ until (retrycount <= 0) or (bindresult);
\r
\r
\r
- If
{$ifndef win32}Not{$endif} Bind(fd[a],inAddrtemp,inaddrsize(inaddrtemp)
) Then begin
\r
+ If
(not bindresult
) Then begin
\r
{$ifdef win32}
\r
raise Exception.create('unable to bind '+inttostr(WSAGetLastError));
\r
{$else}
\r
{$ifdef win32}
\r
raise Exception.create('unable to bind '+inttostr(WSAGetLastError));
\r
{$else}
\r