Sir, I have made a library for Android use CT6.50 and found that is BUG in netdb.pp
the file is located in "/usr/local/codetyphon/fpcsrc/packages/fcl-net/src/netdb.pp"
when compile for Android, it use these code for DNS:
Function GetDNSServers: Integer;
var
i: integer;
s: string;
H : THostAddr;
begin
Result:=0;
SetLength(DNSServers, 9);
for i:=1 to 9 do
begin
try
s:=GetSystemProperty(PAnsiChar('net.dns' + IntToStr(i)));
except
s := '';
end;
if s = '' then
break;
H:=StrToNetAddr(s);
if H.s_bytes[1] <> 0 then
begin
DNSServers[Result]:=H;
Inc(Result);
end;
end;
SetLength(DNSServers, Result);
end;
But on Android O and later, Google banned call to "net.dns", these code will take no affect and returns empty DNS server.
My solution is to add a default DNS Server and make it work again.
Function GetDNSServers: Integer;
var
i: integer;
s: string;
H : THostAddr;
begin
Result:=0;
SetLength(DNSServers, 9);
for i:=1 to 9 do
begin
try
s:=GetSystemProperty(PAnsiChar('net.dns' + IntToStr(i)));
except
s := '';
end;
if s = '' then
break;
H:=StrToNetAddr(s);
if H.s_bytes[1] <> 0 then
begin
DNSServers[Result]:=H;
Inc(Result);
end;
end;
if (Result = 0) then begin
H := StrToNetAddr('8.8.8.8');
DNSServers[0]:=H;
Inc(Result);
end;
SetLength(DNSServers, Result);
end;
Then, the library on Android O and later works fine.
Would CT6.60 take my suggestion and fix the bug?