Bug #78825 [Opn]: stream_socket_client works slower than except

From: Date: Sun, 17 Nov 2019 12:33:52 +0000
Subject: Bug #78825 [Opn]: stream_socket_client works slower than except
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-223757@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78825&edit=1 ID: 78825 User updated by: vibbow at hotmail dot com Reported by: vibbow at hotmail dot com Summary: stream_socket_client works slower than except Status: Open Type: Bug Package: Sockets related Operating System: Windows Server 2019 PHP Version: 7.3.11 Block user comment: N Private report: N New Comment: This issue can be reproduced on Windows platform only, on Linux everything works fine. This issue may also affect php extension who used php_stream API, like phpredis. Previous Comments: ------------------------------------------------------------------------ [2019-11-17 12:28:30] vibbow at hotmail dot com Description: ------------ In my test script, I use two method to create a tcp connection (to another pc in LAN), one is socket_connect, another is stream_socket_client. Since those two code snips doing the same thing, they should have same time cost. But on Windows platform, stream_socket_client are must slower than except. socket_create are using less 1ms in average, stream_socket_client are using around 10ms in average. Can be reproduced from PHP 7.1 to 7.3 Can be reproduced on Windows 2019 & Windows 10 1909. Test script: --------------- <?php $begin = microtime(true); $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); socket_connect($socket, '192.168.163.110', 6379); $end = microtime(true); echo ($end - $begin) * 1000 . PHP_EOL; $begin = microtime(true); $fp = stream_socket_client("tcp://192.168.163.110:6379"); $end = microtime(true); echo ($end - $begin) * 1000 . PHP_EOL; Expected result: ---------------- socket_create & stream_socket_client should use similier time cost Actual result: -------------- D:\Websites>php test.php 1.1060237884521 10.412216186523 stream_socket_client use 10 times time than socket_create ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78825&edit=1

« previous php.bugs (#223757) next »