|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20397 UDP connections dont respect Timeouts on Reads
Submitted: 2002-11-12 11:33 UTC Modified: 2002-12-01 16:34 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: xf_vito at hotmail dot com Assigned:
Status: No Feedback Package: Sockets related
PHP Version: 4.2.3 OS: linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2002-11-12 11:33 UTC] xf_vito at hotmail dot com
I create a udp connection using fsockopen and before all my reads I set a socket timeout.  The timeouts are never respected, because if this situation arises, I time out with FATAL ERROR: timed out greater than 30 sec msg from the server.  

I want to be able to catch this before reaching the FATAL ERROR.

The behaviour can be seen at our website  Click on the SERVERS button to see the page in action.  60% of the time it works great rest it will Fatal, hit the Refresh to cause the error to occur quicker.
I can make the code available upon request.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-11-12 13:44 UTC]
How are you setting the timeout value? The timeout value specified as the 5th argument to fsockopen() is only the timeout for the connection initiation. The read/write timeouts should be set via the stream_set_timeout() (CVS) or set_socket_timeout() in older versions.
 [2002-11-13 07:36 UTC] xf_vito at hotmail dot com
Here is a snippet of the code, I tried set_socket_timeout it didnt work.  this is using socket_set_timeout and it doesnt work either.
  function getrules()

    set_socket_blocking($this->socket, FALSE);
    $this->rules[firstchunk]=$inbyte . fread($this->socket,3);


  function waitstart()
    socket_set_timeout($this->socket, 0, 500);
	  socket_set_timeout($this->socket, 0, 500);
    return $inbyte;
  function getstring()
   socket_set_timeout($this->socket, 0, 500);
    while($inbyte != "\0")
	  socket_set_timeout($this->socket, 0, 500);
    return $string;
 [2002-11-20 07:59 UTC] xf_vito at hotmail dot com
seems the problem is with fread and socket timeout changed to fgetc and all is well works the way it should
but fread and udp and socket timeout has some problem.
 [2002-11-20 10:05 UTC]
Can you clarify what the problem is?
And can you trim down the code to something small, preferably using some standard service so that we can reproduce it here?

$fp = fsockopen(...)
fwrite($fp, "foo");
$data = fread($fp, 1);

Tell us what you expect to happen, and what does actually
happen.  Is PHP returning too soon, waiting too long?

UDP is a connectionless protocol, so you have to write your scripts to take that fact into account.
Also, please only test with a PHP 4.3 RC as this is where any fix would be made (4.2 is very old code compared to 4.3).

 [2002-12-01 16:34 UTC]
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jul 15 22:01:28 2024 UTC