var\r
inAddrtemp : TInetSockAddrV;\r
biniptemp:tbinip;\r
- a,retrycount:integer;\r
+ a,retrycount,porttemp:integer;\r
bindresult:boolean;\r
begin\r
biniptemp := getcurrentsystemnameserverbin(id);\r
for a := 0 to numsockused-1 do begin\r
retrycount := 5;\r
repeat\r
- makeinaddrv(biniptemp,inttostr( 1024 + randominteger(65536 - 1024) ),inaddrtemp);\r
+ if (retrycount <= 1) then begin\r
+ porttemp := 0; //for the last attempt let the OS decide\r
+ end else begin\r
+ porttemp := 1024 + randominteger(65536 - 1024);\r
+ end;\r
+\r
+ makeinaddrv(biniptemp,inttostr( porttemp ),inaddrtemp);\r
\r
fd[a] := Socket(biniptemp.family,SOCK_DGRAM,0);\r
bindresult := {$ifdef win32}Not{$endif} Bind(fd[a],inAddrtemp,inaddrsize(inaddrtemp));\r