Bug #74857 [NEW]: stream_socket_shutdown and fclose didn't close the TCP connection

From: Date: Wed, 05 Jul 2017 02:23:58 +0000
Subject: Bug #74857 [NEW]: stream_socket_shutdown and fclose didn't close the TCP connection
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-209814@lists.php.net to get a copy of this message
From: 452476865 at qq dot com Operating system: ubuntu PHP version: 5.6.30 Package: Streams related Bug Type: Bug Bug description:stream_socket_shutdown and fclose didn't close the TCP connection Description: ------------ REF Bug Report: https://bugs.php.net/bug.php?id=74834 i test fclose() method ,but TCP connection still on TIME_WAIT status. Test script: --------------- ========================== method one ========================== function connectRedis($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); fclose($socket); } $host = '192.168.2.243'; $port = 7000; for($i=0; $i<100; $i++){ connectRedis($host, $port); } ========================== method two ========================== function connectRedis($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); fclose($socket); } $host = '192.168.2.243'; $port = 7000; for($i=0; $i<100; $i++){ connectRedis($host, $port); } 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 bug report at https://bugs.php.net/bug.php?id=74857&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74857&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74857&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74857&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=74857&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=74857&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=74857&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=74857&r=needscript Try newer version: https://bugs.php.net/fix.php?id=74857&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=74857&r=support Expected behavior: https://bugs.php.net/fix.php?id=74857&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=74857&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=74857&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=74857&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74857&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=74857&r=dst IIS Stability: https://bugs.php.net/fix.php?id=74857&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=74857&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=74857&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=74857&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=74857&r=mysqlcfg

« previous php.bugs (#209814) next »