Bug #16680 Updated: socket_read() does not have the described behaviour ...
| From: | mfischer@php.net | Date: | Sat, 04 May 2002 23:37:47 +0000 |
| Subject: | Bug #16680 Updated: socket_read() does not have the described behaviour ... | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-6928@lists.php.net to get a copy of this message | ||
ID: 16680
Updated by: mfischer@php.net
Reported By: tech@kalyweb.com
Status: Feedback
Bug Type: Sockets related
Operating System: Windows 9x
PHP Version: 4.2.0
New Comment:
How did you test sending data to your php script which received the
data? I've noticed that the telnet version shipped with windows does by
default transmit every character immidiately over the line (hence
resulting only in single characters sent). If I telnet from a linux
host to the script running under win32 I recevied the whole data only
after I pressed return.
I've tested it with this simple script:
<?
error_reporting(E_ALL);
if (false === ($s = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)))
exit;
if (false === socket_bind($s, '0.0.0.0', 8765))
exit;
if (false === socket_listen($s, 10))
exit;
if (false === ($t = socket_accept($s)))
exit;
while ($data = socket_read($t, 1024)) {
var_dump($data);
}
?>
Previous Comments:
------------------------------------------------------------------------
[2002-05-04 19:07:35] mfischer@php.net
Please try with CVS HEAD and report back.
------------------------------------------------------------------------
[2002-05-04 13:19:44] gilles@clixicon.nl
i have exactly the same problem with win2000.
it closes the connection immidiatly after the first received char.
that little scriptlet upthere seems to be be a way around this.
is this a bug or is it suppost to work like this?
------------------------------------------------------------------------
[2002-04-18 09:57:00] tech@kalyweb.com
In the documentation, it's written that socket_read() reads data from
the socket until a \n, \t, \0.... or until the end of the buffer.
But under win32 it reads only 1 char.
This would be fixed.
Just use instead :
$buf="";
while (substr($buf,-1)!="\n") {
$buf.=socket_read($socket,1);
}
I've put 1 here, but you can write 16777216 it'll continue to give back
only 1 char.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=16680&edit=1