Edit report at http://bugs.php.net/bug.php?id=52848&edit=1
ID: 52848 Updated by: srina...@php.net Reported by: php dot net at phrozenbyte dot de Summary: Processing out-of-band data doesn't work Status: To be documented Type: Bug Package: Streams related Operating System: Ubuntu 10.04 Lucid Lynx PHP Version: 5.3.3 Block user comment: N New Comment: few additional comments on Linux/Solaris socket implementations, when you send with MSG_OOB flags set, only the last byte is recvd. the subsequent recv call will flush out the rest of the bytes. for example, in your example,if you edit it like below you will notice this more clearly: client script <?php $socket = stream_socket_client('tcp://127.0.0.1:1234'); stream_socket_sendto($socket, '123456789', STREAM_OOB); fclose($socket); ?> server (with 2 recv calls even though client is sending only one send call.) <?php $server = stream_socket_server('tcp://127.0.0.1:1234'); stream_set_timeout($server, 180); $socket = stream_socket_accept($server); echo "Data: '".stream_socket_recvfrom($socket, 100, STREAM_OOB)."'\n"; echo "Data: '".stream_socket_recvfrom($socket, 100)."'\n"; ?> Hope this clarifies I don't think this is an issue with PHP. Previous Comments: ------------------------------------------------------------------------ [2010-09-15 22:17:16] php dot net at phrozenbyte dot de When you're sending data out-of-band (one or more bytes make no difference) and the client socket is in $read and $except of stream_select() the socket will be available every time in both arrays. ------------------------------------------------------------------------ [2010-09-15 20:41:18] php dot net at phrozenbyte dot de Ok, thanks. As cataphract at php dot net mentioned first there are situations on which even that single byte isn't shown. I'm not able to reproduce the bug, the only possibility is to repeat running my test server and client. After some trys the script will result in OOB-Data 1/2: '' OOB-Data 2/2: '' Data 1/2: '12345678' Data 2/2: '' ------------------------------------------------------------------------ [2010-09-15 16:15:20] cataphr...@php.net It should be documented in stream_socket_sendto and stream_socket_recvfrom, that OOB data can be only one byte long. ------------------------------------------------------------------------ [2010-09-15 16:13:20] cataphr...@php.net "In Transmission Control Protocol (TCP), the OOB data block is always one byte. Therefore, if you send multiple-byte OOB data, only the last byte of the OOB data is retrieved. The remaining data is treated like normal data." See also http://support.microsoft.com/kb/830597 ------------------------------------------------------------------------ [2010-09-15 14:44:54] cataphr...@php.net Sorry, correction: Windows presented the same behavior. ------------------------------------------------------------------------ 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/bug.php?id=52848 -- Edit this bug report at http://bugs.php.net/bug.php?id=52848&edit=1