[fpc-pascal] Ethernet Relays
James Richters
james at productionautomation.net
Tue Sep 8 03:15:31 CEST 2020
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
More information about the fpc-pascal
mailing list