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

From: Date: Sun, 17 Nov 2019 12:28:30 +0000
Subject: Bug #78825 [NEW]: stream_socket_client works slower than except
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-223756@lists.php.net to get a copy of this message
From:             vibbow at hotmail dot com
Operating system: Windows Server 2019
PHP version:      7.3.11
Package:          Sockets related
Bug Type:         Bug
Bug description:stream_socket_client works slower than except

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 bug report at https://bugs.php.net/bug.php?id=78825&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=78825&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=78825&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=78825&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=78825&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=78825&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=78825&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=78825&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=78825&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=78825&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=78825&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=78825&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=78825&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=78825&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=78825&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=78825&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=78825&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=78825&r=mysqlcfg


Thread (24 messages)

« previous php.bugs (#223756) next »