Bug->Doc #71951 [Ver->Opn]: stream_socket_shutdown(..., STREAM_SHUT_RD) will not shutdown read on Linux
| From: | krakjoe@php.net | Date: | Mon, 04 Apr 2016 07:54:00 +0000 |
| Subject: | Bug->Doc #71951 [Ver->Opn]: stream_socket_shutdown(..., STREAM_SHUT_RD) will not shutdown read on Linux | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-13383@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71951&edit=1
ID: 71951
Updated by: krakjoe@php.net
Reported by: grzegorz129 at gmail dot com
Summary: stream_socket_shutdown(..., STREAM_SHUT_RD) will not
shutdown read on Linux
-Status: Verified
+Status: Open
-Type: Bug
+Type: Documentation Problem
Package: Streams related
Operating System: Linux
PHP Version: 7.0.5
Block user comment: N
Private report: N
New Comment:
On OSX (BSD) the kernel space read buffer is emptied when the socket is shutdown.
On Linux, it only rejects further packets (so the other side cannot write).
A note in the documentation would be nice.
Previous Comments:
------------------------------------------------------------------------
[2016-04-04 03:34:18] grzegorz129 at gmail dot com
Edit: "Expected result" was accidentally switched with "Actual result".
------------------------------------------------------------------------
[2016-04-04 03:32:49] grzegorz129 at gmail dot com
Description:
------------
Following test script works as expected on OS X, but not on Linux.
System details:
- Linux X 4.3.0-1-amd64 #1 SMP Debian 4.3.5-1 (2016-02-06) x86_64 GNU/Linux
- Debian stretch/sid
Test script:
---------------
<?php
$server = stream_socket_server('tcp://127.0.0.1:9999');
$clientOnClient = stream_socket_client('tcp://127.0.0.1:9999');
$clientOnServer = stream_socket_accept($server, 0.5);
var_dump(stream_set_chunk_size($clientOnServer, 1));
var_dump(stream_set_read_buffer($clientOnServer, 1));
fwrite($clientOnClient, 'ping');
var_dump(fread($clientOnServer, 2));
stream_socket_shutdown($clientOnServer, STREAM_SHUT_RD);
var_dump(fread($clientOnServer, 2));
Expected result:
----------------
int(----)
int(0)
string(2) "pi"
string(2) "ng"
Actual result:
--------------
int(8192)
int(0)
string(2) "pi"
string(0) ""
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71951&edit=1