#32979 [Opn]: socket stream opened with stream_socket_client doesnt work with stream_select

From: Date: Sun, 08 May 2005 20:46:57 +0000
Subject: #32979 [Opn]: socket stream opened with stream_socket_client doesnt work with stream_select
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-78772@lists.php.net to get a copy of this message
 ID:               32979
 User updated by:  mjpph at stardust dot fi
 Reported By:      mjpph at stardust dot fi
 Status:           Open
 Bug Type:         CGI related
 Operating System: Linux (Fedora Core 3)
 PHP Version:      5CVS-2005-05-08 (dev)
 New Comment:

Also, adding "fread($c,1);" after stream_socket_client and before the
while loop enables correct functionality of the stream_select function
from that pont on.


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

[2005-05-08 22:18:29] mjpph at stardust dot fi

Description:
------------
Using stream_socket_client or stream_socket_server to open a connection
fails to report correct values with stream_select. Using fread to get
one byte before stream_select suddenly makes stream_select work as
expected.
Without it stream_select returns 0 changed streams even though there is
data waiting. Service used as an endpoint is persistent and doesn't
close the connection after it's output. PHP is CLI-version.

Reproduce code:
---------------
$c = stream_socket_client("tcp://127.0.0.1:80");
while (1)
{
  $streams = array($c);
  if (stream_select($streams, $write=NULL, $except=NULL, 0, 5000)) {
    print "Data received\n";
  }
}

// IP:Port can be anything which outputs something after connection.

Expected result:
----------------
Text "Data received" after connection and output from the service. The
service can be anything which just outputs something right after
connect.

Actual result:
--------------
Nothing. stream_select returns 0 even though there is data waiting.


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


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


Thread (50 messages)

« previous php.bugs (#78772) next »