Recent

Author Topic: 2 Problemas time out ou ping.  (Read 2273 times)

ClaudioBorba

  • Newbie
  • Posts: 2
2 Problemas time out ou ping.
« on: March 18, 2024, 02:17:21 pm »
Olá, compilando para LInux estamos com 2 problemas:
1 - Time out de conexão firebird demora quase 3 minutos no linux.
2-  Ping só funciona se executar o aplicativo como root.

Linux Mint 21.3
Firebird 4.0
Lazrus 3.0

ClaudioBorba

  • Newbie
  • Posts: 2
Re: 2 Problemas time out ou ping.
« Reply #1 on: March 21, 2024, 07:24:47 pm »
Resolvido.
olá, pesquisando bastante consegui fazer com esse codigo ping para linux e windows.

unit uUtil;

{$mode ObjFPC}{$H+}

interface

uses
  Classes, SysUtils , process;

function PingHost(Host:String) : Boolean;

implementation

function PingHost(Host: String): Boolean;
var Proc: TProcess;
    St :TStringList;
begin
 Proc := TProcess.Create(nil);
 St   := TStringList.Create;
 {$IFDEF WINDOWS}
 Proc.Executable := 'cmd';
 Proc.Executable := 'ping';
 Proc.Parameters.Add(Host);
 Proc.Options    := Proc.Options + [poWaitOnExit, poUsePipes];
 Proc.Execute;
 St.LoadFromStream(Proc.Output);
 Result := (Pos('Resposta',St.Text) > 0);
 {$ELSE}
 Proc.Executable := 'ping';
 Proc.Parameters.Add('-c');
 Proc.Parameters.Add('2');
 Proc.Parameters.Add(Host);
 Proc.Options    := Proc.Options + [poWaitOnExit, poUsePipes];
 Proc.Execute;
 St.LoadFromStream(Proc.Output);
 Result := (Pos('icmp_seq',St.Text) > 0);

 {$ENDIF}

end;

end.

 

TinyPortal © 2005-2018