Hi All,

I want to Use Synapse for Scan on Internal Network where is the FireBird 
Server...

I'm trying to do this, opening a TCP connection on Firebird's port (3050)... in 
a Thread... If it can connect, so (probally) I have a Firebird Server on this 
IP.

It works only when a few Threads are instanced, but when more than 10 threads 
are running, it don't connect...

Exemple:
FireBird Server is on IP 192.168.1.95

Scanning from 192.168.1.90 to 192.168.1.95... correctlly finds the Server on 
192.168.1.95
Scanning from 192.168.1.80 to 192.168.1.95... can't find the Server on 
192.168.1.95

(Using 1 second for TimeOut)

Here is the code:


{ TThreadScanPort }

 TThreadScanPort = class(TThread)
  private
    fsPort: String ;
    fsHost: String ;
    fsFound : Boolean ;
  protected
    procedure Execute; override;
  public
    constructor Create( Host: String; Port: Integer) ;

    property Found : Boolean read fsFound ;
  end;

......

constructor TThreadScanPort.Create(Host: String; Port: Integer);
begin
  FreeOnTerminate := True ;
  fsHost      := Host ;
  fsPort      := IntToStr(Port) ;
  fsFound     := False ;

  inherited Create( False );
end;

procedure TThreadScanPort.Execute;
Var
  sock: TBlockSocket;
  Erro: Integer;
begin
  sock := TBlockSocket.Create;
  try
     sock.Connect( fsHost, fsPort ) ;
     Erro    := sock.LastError ;
     fsFound := (Erro = 0);
     sock.CloseSocket;
  finally
     sock.Free ;
  end ;
end;


Using the TThreadScanPort with a TimeOut loop

Function ScanTCPPort( Host : String; Port, TimeOut : Integer ) : Boolean ;
Var
  TimeToEnd      : TDateTime ;
  ThreadScanPort : TThreadScanPort ;
begin
  { Criando Thread para monitorar a tentaiva de conexao a porta }
  Result         := False ;
  TimeToEnd      := IncMilliSecond(now,TimeOut) ;
  ThreadScanPort := TThreadScanPort.Create( Host, Port );
  try
     while (not Result) do
     begin
        if ThreadScanPort.Terminated then
           exit ;

        Result := ThreadScanPort.Found ;
        if Result then
           exit ;

        if now > TimeToEnd then
           exit ;

        Application.ProcessMessages ;
        sleep(100) ;
     end ;
  finally
     ThreadScanPort.Terminate ;
  end ;
end ;


What I'm doing wrong ?

(PS: sorry my poor english)

 []s Daniel

Conheça o Projeto ACBr - Automaçao Comercial Brasil
DJSystem a Loja Patrocinadora do ACBr


      Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com
------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
synalist-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synalist-public

Reply via email to