php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36314 Incorrect behavior of socket_read when used with PHP_NORMAL_READ
Submitted: 2006-02-07 04:59 UTC Modified: 2006-02-07 12:30 UTC
From: flachi at gmail dot com Assigned:
Status: Not a bug Package: Sockets related
PHP Version: 4.4.2 OS: Windows
Private report: No CVE-ID: None
 [2006-02-07 04:59 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-02-07 12:30 UTC] tony2001@php.net
Duplicate of bug #21197.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 21:01:29 2024 UTC