문제

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?

도움이 되었습니까?

해결책

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;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top