Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Internet (https://www.clubdelphi.com/foros/forumdisplay.php?f=3)
-   -   método post error timeout (https://www.clubdelphi.com/foros/showthread.php?t=86955)

petete2008 27-10-2014 16:52:19

método post error timeout
 
Hola , tengo el siguiente codigo

Código:

function PostExample: string;
var  lHTTP: TIdHTTP;  lParamList: TStringList;
begin  lParamList := TStringList.Create; 
lParamList.Add('id=1');   
lHTTP := TIdHTTP.Create(nil); 
try   
Result := lHTTP.Post('http://blahblahblah...', lParamList); 
finally   
 lHTTP.Free;   
 lParamList.Free; 
 end;
end;

Mi problema es que a veces funciona y otras veces. Las veces que no funciona me devuelve el siguiente mensaje :

Error encountered during POST: Socket Error #10060
Connection time out

Mi pregunta es si sería posible de una forma sencilla hacer que lo vuelva a reintentar pasado por ejemplo 10 segundos y así sucesivamente con 10 intentos por ejemplos.
Y pasado todo esto si sigue devolviendo error entonces mostrar un error y salir del programa.

Gracias.

Neftali [Germán.Estévez] 27-10-2014 17:26:15

Utiliza un bucle para reintertar N veces y captura el error de conexión con un Try..except.

petete2008 28-10-2014 19:27:24

Gracias, voy hacer lo que tú dices.


La franja horaria es GMT +2. Ahora son las 07:13:01.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi