note 30402 added to ref.sockets
| From: | Benjamin at rack1 dot php dot net | Date: | Mon, 17 Mar 2003 08:46:33 +0000 |
| Subject: | note 30402 added to ref.sockets | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-45407@lists.php.net to get a copy of this message | ||
The talkback example shown on this page has an error, and may not function as intended on newer
versions of PHP.
the line that contains
if (FALSE === ($buf = socket_read ($msgsock, 2048))) {
needs to be
if (FALSE === ($buf = socket_read ($msgsock, 2048, PHP_NORMAL_READ))) {
This is due to changes in how PHP starts socket_read(), and may be confusing to people trying to use
the example.
The way it is, it appears that the socket_read() function is executed as quickly as possible
returning whatever is in it's buffer before an entire line can be sent. Adding PHP_NORMAL_READ
makes it so that the buffer isn't returned until either the buffer length is reached, or a
linefeed is sent.
--
http://www.php.net/manual/en/ref.sockets.php
http://master.php.net/manage/user-notes.php?action=edit+30402
http://master.php.net/manage/user-notes.php?action=delete+30402
http://master.php.net/manage/user-notes.php?action=reject+30402