|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-11-17 03:57 UTC] cheeto_crunch at yahoo dot com
Description: ------------ According to the PHP documentation, http://php.net/manual/en/function.socket-read.php, the type PHP_NORMAL_READ - reading stops at \n or \r. It is supposed to stop that read function after a \n or \r but it does not. How to duplicate: Create a client and a server, both in php. From the server, send multiple fast consecutive socket_write functions to the client. The client will read them all as one packet instead of separating them based on the \n or \r of the packet received. Test script: --------------- Will be pulling my code apart to recreate the bug. This will take some time as I will not be providing my entire code. (It would greatly complicate the issue). PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 16 12:00:01 2025 UTC |
That code never even reaches the call to socket_read(); verify that with $buf = socket_read($hub, 4096, PHP_NORMAL_READ); doDebug("socket_read: $buf"); in client.php. The fact that socket_recv() returns all the values at once is a race condition - on my Windows machine I get one at a time, but if I sleep(1) after the hubConnect() then I get the same results as you. (It also doesn't do the PHP_NORMAL_READ thing, of course.) Now, if I keep the sleep(1) and new doDebug, and remove the while loop on socket_recv(), socket_read() kicks in and gives one value at a time. Can you revise the repro code, or does what I just said explain away your problem?