Bug #74834 [Com]: stream_socket_shutdown don't work!
Edit report at https://bugs.php.net/bug.php?id=74834&edit=1
ID: 74834
Comment by: kelunik@php.net
Reported by: 452476865 at qq dot com
Summary: stream_socket_shutdown don't work!
Status: Open
Type: Bug
Package: Streams related
Operating System: ubuntu
PHP Version: 5.6.30
Block user comment: N
Private report: N
New Comment:
No, stream_socket_shutdown doesn't close a connection, use fclose for that.
Previous Comments:
------------------------------------------------------------------------
[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
Thread (4 messages)