- Posts: 9
- Thank you received: 0
- Forum
- CodeTyphon Studio
- CT Platforms Development
- [bug report] bug on sending http request on Android
×
CodeTyphon Platforms (Win32/64, GTK2/3/4, QT4/5, Cocoa, FpGUI etc) Development, discussions and problems
Idea [bug report] bug on sending http request on Android
- rarnu
-
Topic Author
- Offline
- New Member
-
Less
More
3 years 9 months ago #12307
by rarnu
[bug report] bug on sending http request on Android was created by rarnu
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:
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.
Then, the library on Android O and later works fine.
Would CT6.60 take my suggestion and fix the bug?
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?



Please Log in or Create an account to join the conversation.
- Sternas Stefanos
-
- Offline
- Moderator
-
- Ex Pilot, M.Sc, Ph.D
3 years 9 months ago #12308
by Sternas Stefanos
PilotLogic Architect and Core Programmer
Replied by Sternas Stefanos on topic [bug report] bug on sending http request on Android
Thanks Sir
we add your fix to LAB CT 6.6 in file
codetyphon/fpcsrc/packages/fcl-net/src/netdb.pp"
we add your fix to LAB CT 6.6 in file
codetyphon/fpcsrc/packages/fcl-net/src/netdb.pp"
PilotLogic Architect and Core Programmer
Attachments:
Please Log in or Create an account to join the conversation.