Lazarus

Programming => Networking and Web Programming => Topic started by: GAN on January 14, 2020, 10:00:19 pm

Title: Simple question about TFPHTTPClient.IOTimeout
Post by: GAN on January 14, 2020, 10:00:19 pm
The time unit is milliseconds?
Title: Re: Simple question about TFPHTTPClient.IOTimeout
Post by: lucamar on January 15, 2020, 12:23:26 pm
It's set in the socket as:

Code: Pascal  [Select][+][-]
  1. FIOTimeout:=(time.tv_sec*1000)+(time.tv_usec div 1000);

so yes, it seems IOTimeOut is millliseconds.
Title: Re: Simple question about TFPHTTPClient.IOTimeout
Post by: GAN on January 15, 2020, 09:22:10 pm
Hi @lucamar, yes I saw this formula and then posted the question, because it is not clear for me
Code: Pascal  [Select][+][-]
  1. (time.tv_sec*1000)
appears to be seconds.
Title: Re: Simple question about TFPHTTPClient.IOTimeout
Post by: Thaddy on January 15, 2020, 09:43:18 pm
Well: http://man7.org/linux/man-pages/man2/setitimer.2.html https://en.cppreference.com/w/c/chrono/timespec https://www.gnu.org/software/libc/manual/html_node/Elapsed-Time.html

Why do people not Read The Fine   8-) Manuals.... O:-) O:-)

Resolution is either seconds or nanoseconds.
Title: Re: Simple question about TFPHTTPClient.IOTimeout
Post by: GAN on January 15, 2020, 11:40:40 pm
@Thaddy thanks for the link, but they must be milliseconds because with values less than 200 (approx.) I get 90% errors and with value of 1000/1500 works fine.

Title: Re: Simple question about TFPHTTPClient.IOTimeout
Post by: lucamar on January 16, 2020, 02:02:02 pm
Hi @lucamar, yes I saw this formula and then posted the question, because it is not clear for me
Code: Pascal  [Select][+][-]
  1. (time.tv_sec*1000)
appears to be seconds.

Of course: time.tv_sec is seconds, which multiplied by 1000 give milliseconds; time.tv.usec are microseconds which divided by 1000 give, again, milliseconds.

The links posted by Thaddy are (somewhat) useful to know why a time struct has to be used: for the system call that implements the timer. But Thaddy, note:

Resolution is either seconds or nanoseconds.

That is correct when you (have to) use the struct timespec, but the structure used here is timeval, which has only seconds and microseconds.

HTH!
Title: [SOLVED] Re: Simple question about TFPHTTPClient.IOTimeout
Post by: GAN on January 16, 2020, 10:49:06 pm
Thanks @lucamar and @Thaddy.
TinyPortal © 2005-2018