Bug #16877 Updated: socket_read() only gets one character (no matter what length set)
| From: | administrator at zinious dot com | Date: | Mon, 15 Jul 2002 13:37:48 +0000 |
| Subject: | Bug #16877 Updated: socket_read() only gets one character (no matter what length set) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-14207@lists.php.net to get a copy of this message | ||
ID: 16877
Updated by: administrator@zinious.com
Reported By: webmaster@red-sub-tech.ws
Status: No Feedback
Bug Type: Sockets related
Operating System: Windows 2000 Profesional
PHP Version: 4.2.0
New Comment:
Looks like a bug in the code.
I'm using Windows 2000 Server (same OS family) and am reading multiple
bytes of text at one read.
Previous Comments:
------------------------------------------------------------------------
[2002-06-05 01:00:07] php-bugs@lists.php.net
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
------------------------------------------------------------------------
[2002-05-04 19:06:00] mfischer@php.net
Please try with CVS HEAD and report back. But do *not* rely on the
manuals sample script, they're outdated.
------------------------------------------------------------------------
[2002-04-27 15:07:18] webmaster@red-sub-tech.ws
Note this script was taken DIRECTLY from the PHP Manual (which you guys
have yet to update with the new socket fixes). And I used this in
Windows with a batch file (only one line on the batch file:
@c:\PHP\php-cli.exe -q c:\php\server.php )
Script:
error_reporting (E_ALL);
/* Allow the script to hang around waiting for connections. */
set_time_limit (0);
/* Turn on implicit output flushing so we see what we're getting
* as it comes in. */
ob_implicit_flush ();
$address = 'xxx.xxx.x.xxx;
$port = 10000;
if (($sock = socket_create (AF_INET, SOCK_STREAM, 0)) < 0) {
echo "socket_create() failed: reason: " . socket_strerror ($sock) .
"\n";
}
if (($ret = socket_bind ($sock, $address, $port)) < 0) {
echo "socket_bind() failed: reason: " . socket_strerror ($ret) .
"\n";
}
if (($ret = socket_listen ($sock, 5)) < 0) {
echo "socket_listen() failed: reason: " . socket_strerror ($ret) .
"\n";
}
do {
if (($msgsock = socket_accept($sock)) < 0) {
echo "socket_accept() failed: reason: " . socket_strerror
($msgsock) . "\n";
break;
}
/* Send instructions. */
$msg = "\nWelcome to the PHP Test Server. \n" .
"To quit, type 'quit'. To shut down the server type
'shutdown'.\n";
socket_write($msgsock, $msg, strlen($msg));
do {
if (FALSE === ($buf = socket_read ($msgsock, 2048))) {
echo "socket_read() failed: reason: " . socket_strerror
($ret) . "\n";
break 2;
}
if (!$buf = trim ($buf)) {
continue;
}
if ($buf == 'quit') {
break;
}
if ($buf == 'shutdown') {
socket_close ($msgsock);
break 2;
}
$talkback = "PHP: You said '$buf'.\n";
socket_write ($msgsock, $talkback, strlen ($talkback));
echo "$buf\n";
} while (true);
socket_close ($msgsock);
} while (true);
socket_close ($sock);
------------------------------------------------------------------------
[2002-04-27 14:57:44] mfischer@php.net
Please include a short, self-contained sample script (it works for me
with cvs head).
------------------------------------------------------------------------
[2002-04-27 14:43:10] webmaster@red-sub-tech.ws
The socket_read() function does not work properly, say I do this:
$text = socket_read($message_socket, 2048);
It will only get 1 character even though I said 2048 characters.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/16877
--
Edit this bug report at http://bugs.php.net/?id=16877&edit=1