* * *

Author Topic: TFPHTTPCLIENT iotimeout how to use?  (Read 193 times)

vonskie

  • Full Member
  • ***
  • Posts: 125
TFPHTTPCLIENT iotimeout how to use?
« on: August 21, 2017, 06:52:38 pm »
Is iotimeout:= to the number of seconds a time out will occur in or ms or is it a off and on option 1 means it will timeout...

I can find no to little doc on it.




Leledumbo

  • Hero Member
  • *****
  • Posts: 7647
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: TFPHTTPCLIENT iotimeout how to use?
« Reply #1 on: August 21, 2017, 09:13:12 pm »
It is simply delegated to underlying TInetSocket instance, which in turn calls setsockopt with that value for both SO_RCVTIMEO and SO_SNDTIMEO. The corresponding code:
Code: Pascal  [Select]
  1.   {$ifdef windows}
  2.   opt := AValue;
  3.   E:=fpsetsockopt(Handle, SOL_SOCKET, SO_RCVTIMEO, @opt, 4)<>0;
  4.   if not E then
  5.     E:=fpsetsockopt(Handle, SOL_SOCKET, SO_SNDTIMEO, @opt, 4)<>0;
  6.   {$endif windows}
  7.   {$ifdef unix}
  8.   time.tv_sec:=avalue div 1000;
  9.   time.tv_usec:=(avalue mod 1000) * 1000;
  10.   E:=fpsetsockopt(Handle, SOL_SOCKET, SO_RCVTIMEO, @time, sizeof(time))<>0;
  11.   if not E then
  12.     E:=fpsetsockopt(Handle, SOL_SOCKET, SO_SNDTIMEO, @time, sizeof(time))<>0;
  13.   {$endif}
  14.   if E then
  15.     Raise ESocketError.Create(seIOTimeout,[AValue]);
  16.  
Reading it (unix part) easily says that the value is in milliseconds unit. Windows one although differs in parameter, behaves the same (find SO_SNDTIMEO in this page).

We still lack documentation for a lot of (DRY supporting) things, but the source code is there and won't lie, so you can always inspect it yourself.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus