Welcome, Guest
Username: Password: Remember me
CodeTyphon Platforms (Win32/64, GTK2/3/4, QT4/5/6, Cocoa, FpGUI etc) Development, discussions and problems
  • Page:
  • 1

TOPIC:

[bug report] bug on sending http request on Android 6 years 2 months ago #12307

  • rarnu
  • rarnu's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 9
  • Thank you received: 0
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? B) B) B)

Please Log in or Create an account to join the conversation.

[bug report] bug on sending http request on Android 6 years 2 months ago #12308

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4535
  • Thank you received: 1114
Thanks Sir
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.

  • Page:
  • 1