[fpc-pascal] Ethernet Relays

Michael Van Canneyt michael at freepascal.org
Tue Sep 8 08:50:38 CEST 2020


Add the ssockets unit to your uses clause.

Michael

On Mon, 7 Sep 2020, James Richters via fpc-pascal wrote:

> When I try to compile either of the examples below, I get Error: Identifier not found "ESocketError" 
> Any ideas? 
>
> James
>
>
> Yes, catch the ESocketError in a try..except:
>
> Try
>   S:=TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/30000/15');
> except
>   On E: ESocketError do
>     Writeln('Could not connect to server'); end;
>
>> Is there a way to change the amount of time before the timeout?
>
> Yes, but then you need to create an instance, i.e. the Simple* commands won't do that for you:
>
> Instead, it will look like this:
>
> uses fphttpclient;
>
> Var
>   C : TFPHTTPClient;
>
> begin
>   C:=TFPHTTPClient.Create(Nil);
>   try
>      try
>        C.ConnectTimeout:=10; // Or whatever you think is good
>        C.Get('http://10.10.01.01/30000/15');
>      except
>        On E: ESocketError do
>          Writeln('Could not connect to server');
>      end;
>   finally
>     C.Free;
>   end;
> end;
>
> Michael.
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


More information about the fpc-pascal mailing list