Re: socket timeout being ignored



yawnmoth wrote:
Jerry Stuckle wrote:

yawnmoth wrote:
<snip>

What happens if the fsockopen() takes longer than 5 seconds?

See the note on fsockopen() - the timeout may not be available in all
environments. So a delay due to routing, server load or whatever may
cause the open to take longer than 5 seconds, putting a negative value
in your $timeout. I don't know what PHP will do with a negative value -
maybe convert it to a very large positive value?

That's a good point - it's been fixed :)


Additionally, the timeout restarts every time you go a fgets(). The
server could be sending one line every 4 seconds, for instance. 10
lines would be 40 seconds with no errors.

So I guess I should just use fread with as big a number as possible?
Like pow(2,20) or something?

The fact that fgets (and fread), though, can return empty lines, even
when they're in blocking mode, makes me think that this wouldn't work?
(I made another post about this)


Could be. I haven't seen that occur, but there could be a bug in it. You could try a big fread() call. Don't know what it will do. I haven't used the timeout parm like that. Normally I want to get the results even if it takes a few second.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.



Relevant Pages

  • Re: socket timeout being ignored
    ... See the note on fsockopen- the timeout may not be available in all ... So a delay due to routing, server load or whatever may ... So I guess I should just use fread with as big a number as possible? ...
    (comp.lang.php)
  • Re: FLOCK/FWRITE/FUNLOCK to Message File Question
    ... So, if you want your FREAD call to wait until after the FWRITE's FUNLOCK, ... I do an FCONTROL before the FREAD setting the FREAD timeout to 5 seconds ... if record read successfully then process data and auto delete msgfile record ... To join/leave the list, search archives, change list settings, * ...
    (comp.sys.hp.mpe)
  • Re: FLOCK/FWRITE/FUNLOCK to Message File Question
    ... So, if you want your FREAD call to wait until after the FWRITE's FUNLOCK, the ... FREAD must also surrounded by an FLOCK/FUNLOCK pair. ... I do an FCONTROL before the FREAD setting the FREAD timeout to 5 seconds ... Not really sure if the FLOCK/FUNLOCK is really necessary. ...
    (comp.sys.hp.mpe)
  • Re: FLOCK/FWRITE/FUNLOCK to Message File Question
    ... So, if you want your FREAD call to wait until after the FWRITE's FUNLOCK, the ... FREAD must also surrounded by an FLOCK/FUNLOCK pair. ... I do an FCONTROL before the FREAD setting the FREAD timeout to 5 seconds ... Not really sure if the FLOCK/FUNLOCK is really necessary. ...
    (comp.sys.hp.mpe)
  • Re: [PATCH 1/2] TPM: sysfs functions consolidation
    ... present a pattern when allocating data[] memory space and also when setting its ... A new function was created so that this pattern could be consolidated. ... if (timeout) ...
    (Linux-Kernel)