Question

I'm doing this before post:

FTimeout := 30000;

InternetSetOption(Pointer(@Data), INTERNET_OPTION_CONNECT_TIMEOUT, Pointer(@FTimeOut), SizeOf(FTimeOut));
InternetSetOption(Pointer(@Data), INTERNET_OPTION_SEND_TIMEOUT, Pointer(@FTimeOut), SizeOf(FTimeOut));
InternetSetOption(Pointer(@Data), INTERNET_OPTION_RECEIVE_TIMEOUT, Pointer(@FTimeOut), SizeOf(FTimeOut));

But don't works.

Someone can help?

Was it helpful?

Solution

That should work. You don't say where you call it from, but I call mine in the OnBeforePost handler.

My function looks like this:

function SetTimeout(const HTTPReqResp: THTTPReqResp; Data: Pointer; NumSecs : integer) : boolean;
var
  TimeOut: Integer;
begin
  // Sets the receive timeout. i.e. how long to wait to 'receive' the response
  TimeOut := (NumSecs * 1000);
  try
    InternetSetOption(Data, INTERNET_OPTION_RECEIVE_TIMEOUT,  Pointer(@TimeOut),  SizeOf(TimeOut));
    InternetSetOption(Data, INTERNET_OPTION_SEND_TIMEOUT,  Pointer(@TimeOut),  SizeOf(TimeOut));
  except on E:Exception do
    raise Exception.Create(Format('Unhandled Exception:[%s] while setting timeout to [%d] - ',[E.ClassName, TimeOut, e.Message]));
  end;
end;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top