Edit report at http://bugs.php.net/bug.php?id=52848&edit=1

 ID:                 52848
 Comment by:         php dot net at phrozenbyte dot de
 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:

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: ''


Previous Comments:
------------------------------------------------------------------------
[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.

------------------------------------------------------------------------
[2010-09-15 14:15:06] cataphr...@php.net

I can reproduce it in Linux.



In Windows, the server gets no data at all (the first
stream_socket_recvfrom keeps blocking indefinitely).

------------------------------------------------------------------------
[2010-09-15 04:13:49] php dot net at phrozenbyte dot de

Description:
------------
I'm not sure what's going wrong (stream_socket_sendto() or
stream_socket_recvfrom()) but proccessing out-of-band data doesn't work
correctly. Only the last byte is send as out-of-band data, all other
data is send as usally.

Test script:
---------------
Server:

<?php

$server = stream_socket_server('tcp://127.0.0.1:1234');

$socket = stream_socket_accept($server);

echo "OOB-Data 1/2: '".stream_socket_recvfrom($socket, 1500,
STREAM_OOB)."'\n";

echo "OOB-Data 2/2: '".stream_socket_recvfrom($socket, 1500,
STREAM_OOB)."'\n";

echo "Data 1/2: '".stream_socket_recvfrom($socket, 1500)."'\n";

echo "Data 2/2: '".stream_socket_recvfrom($socket, 1500)."'\n";

fclose($socket);

fclose($server);

?>



Client:

<?php

$socket = stream_socket_client('tcp://127.0.0.1:1234');

stream_socket_sendto($socket, '123456789', STREAM_OOB);

fclose($socket);

?>

Expected result:
----------------
OOB-Data 1/2: '123456789'

OOB-Data 2/2: ''

Data 1/2: ''

Data 2/2: ''

Actual result:
--------------
OOB-Data 1/2: '9'

OOB-Data 2/2: ''

Data 1/2: '12345678'

Data 2/2: ''


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=52848&edit=1

Reply via email to