Bug #74834 [Opn->Nab]: stream_socket_shutdown don't work!
| From: | bwoebi@php.net | Date: | Sat, 01 Jul 2017 10:55:28 +0000 |
| Subject: | Bug #74834 [Opn->Nab]: stream_socket_shutdown don't work! | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-209760@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74834&edit=1
ID: 74834
Updated by: bwoebi@php.net
Reported by: 452476865 at qq dot com
Summary: stream_socket_shutdown don't work!
-Status: Open
+Status: Not a bug
Type: Bug
Package: Streams related
Operating System: ubuntu
PHP Version: 5.6.30
Block user comment: N
Private report: N
New Comment:
If you do not have a well-defined reason for not using fclose(), better use fclose() rather than
stream_socket_shutdown(STREAM_SHUT_RDWR).
It will remain in TIME_WAIT until you actually close the resource (and implicitly the file
descriptor beyond it).
Previous Comments:
------------------------------------------------------------------------
[2017-06-30 10:42:08] kelunik@php.net
No, stream_socket_shutdown doesn't close a connection, use fclose for that.
------------------------------------------------------------------------
[2017-06-30 10:39:21] 452476865 at qq dot com
Description:
------------
stream_socket_shutdown don't close the TCP connection.
this cause TCP connection overflow when high concurrency on WEB server.
i think stream_socket_shutdown should close TCP connection, not just TIME_WAIT status.
Test script:
---------------
<?php
function one($host, $port){
$host = 'tcp://' . $host . ':' . $port;
$socket = @stream_socket_client(
$host,
$errorNumber,
$errorDescription,
ini_get("default_socket_timeout")
);
stream_socket_shutdown($socket, STREAM_SHUT_RDWR);
}
$host = '192.168.2.243';
$port = 7000;
for($i=0; $i<100; $i++){
one($host, $port);
}
echo "done";
?>
Expected result:
----------------
netstat -an |grep '192.168.2.243'
return :
none
Actual result:
--------------
netstat -an |grep '192.168.2.243'
return :
tcp 0 0 192.168.2.66:57336 192.168.2.243:7000 TIME_WAIT
tcp 0 0 192.168.2.66:57282 192.168.2.243:7000 TIME_WAIT
tcp 0 0 192.168.2.66:57222 192.168.2.243:7000 TIME_WAIT
tcp 0 0 192.168.2.66:57298 192.168.2.243:7000 TIME_WAIT
tcp 0 0 192.168.2.66:57236 192.168.2.243:7000 TIME_WAIT
tcp 0 0 192.168.2.66:57318 192.168.2.243:7000 TIME_WAIT
tcp 0 0 192.168.2.66:57398 192.168.2.243:7000 TIME_WAIT
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74834&edit=1