For Programmers: Free Programming Magazines  


Home > Archive > PHP Documentation > November 2005 > #35077 [Opn->Csd]: stream_set_timeout() does not work with stream_socket_recvfrom(









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author #35077 [Opn->Csd]: stream_set_timeout() does not work with stream_socket_recvfrom(
vrana@php.net

2005-11-04, 6:56 pm

ID: 35077
Updated by: vrana@php.net
Reported By: pn2865 at yahoo dot com
-Status: Open
+Status: Closed
Bug Type: Documentation problem
Operating System: *
PHP Version: Irrelevant
New Comment:

This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation
better.

"This function doesn't work with advanced operations like
stream_socket_recvfrom(), use stream_select() with timeout parameter
instead."


Previous Comments:
------------------------------------------------------------------------

[2005-11-03 17:03:28] wez@php.net

It's supposed to work this way; use stream_select() to implement your
own timeout when you're doing "advanced" things like this.
Changing to a documentation problem.

------------------------------------------------------------------------

[2005-11-03 03:12:36] pn2865 at yahoo dot com

Description:
------------
Sample program tries to get data via UDP and never completes if none
received. Use any IP address and port that does (or does not) exist and
you get the same result if that IP does not send a UDP packet to the
system this snippet is run on.

Reproduce code:
---------------
$server_recv = stream_socket_server("udp://192.168.1.100:9999", $errno,
$errstr, STREAM_SERVER_BIND);
if (!$server_recv)
exit ("ERROR: stream_socket_server failed");

set_time_limit(2); // Will not interrupt stream_socket_recvfrom
stream_set_timeout($server_recv,3,0);

$packet=stream_socket_recvfrom($server_r
ecv, 1000);
$info = stream_get_meta_data($server_recv);
if ($info['timed_out'])
echo 'Connection timed out!';
else
echo "Got back '$packet'";

Expected result:
----------------
Should timeout at 3 seconds.

Actual result:
--------------
Never comes back from stream_socket_recvfrom call.


------------------------------------------------------------------------


--
Edit this bug report at http://bugs.php.net/?id=35077&edit=1
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com