#36314 [Opn->Bgs]: Incorrect behavior of socket_read when used with PHP_NORMAL_READ

From: Date: Tue, 07 Feb 2006 11:30:09 +0000
Subject: #36314 [Opn->Bgs]: Incorrect behavior of socket_read when used with PHP_NORMAL_READ
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-93005@lists.php.net to get a copy of this message
 ID:               36314
 Updated by:       tony2001@php.net
 Reported By:      flachi at gmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Sockets related
 Operating System: Windows
 PHP Version:      4.4.2
 New Comment:

Duplicate of bug #21197.


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

[2006-02-07 04:59:01] flachi at gmail dot com

Description:
------------
I tested this also on Linux and it works ok. When I use socket_read
with PHP_NORMAL_READ as third parameter it gaves me a warning and
doesn't take into account the if the socket is blocking. I looked in
the sources but I found nothing that would let me know why is this
happening (maybe in php_read ?). I've seen that there are a lot of bugs
with this function on Win32. A very good ideea would be to rewrite it
from scratch.

Reproduce code:
---------------
  $g = socket_create (AF_INET, SOCK_STREAM, SOL_TCP);
  socket_connect ($g, "helsinki.fi.eu.undernet.org", 6667);
  socket_set_block ($g);
  $s = "USER flachi flachi flachi :flachi\r\nNICK floadssaas\r\n";
  socket_write ($g, $s, strlen ($s));
  while (($s = socket_read ($g, 512, PHP_NORMAL_READ)) !== false) {
echo $s; }
  socket_shutdown ($g, 2); socket_close ($g);

Expected result:
----------------
This should connect to that IRC server and get some lines of code. Here
is how it should work (and does on Linux):

~$ php -q test3.php
NOTICE AUTH :*** Looking up your hostname
NOTICE AUTH :*** Checking Ident
NOTICE AUTH :*** Couldn't look up your hostname
PING :34913160

Actual result:
--------------
This is what I get on Windows. It doesn't receive anything from the IRC
server.

G:\Foo\fbot>php -d output_buffering=8 -d html_errors=off -q test.php
PHP Warning:  socket_read() unable to read from socket [0]: The
operation completed successfully.
 in G:\Foo\fbot\test.php on line 8


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


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


Thread (2 messages)

« previous php.bugs (#93005) next »