Req #79507 [Opn->Csd]: Ability to determin if socket pers. connection is "new" or already estabilished

From: Date: Wed, 22 Apr 2020 09:23:20 +0000
Subject: Req #79507 [Opn->Csd]: Ability to determin if socket pers. connection is "new" or already estabilished
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226718@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79507&edit=1 ID: 79507 User updated by: slawek1211 at gmail dot com Reported by: slawek1211 at gmail dot com Summary: Ability to determin if socket pers. connection is "new" or already estabilished -Status: Open +Status: Closed Type: Feature/Change Request Package: Sockets related Operating System: Every operating systems PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Closing as ftell can be used to do same thing Previous Comments: ------------------------------------------------------------------------ [2020-04-22 09:21:54] slawek1211 at gmail dot com Yes, that's it, so no addition is needed. Thanks ------------------------------------------------------------------------ [2020-04-22 07:15:15] requinix@php.net One of the comments on the pfsockopen() page suggests using ftell() to determine whether the connection is new. Does that do what you need? ------------------------------------------------------------------------ [2020-04-22 07:13:17] slawek1211 at gmail dot com Description: ------------ For client-server connections using persistent sockets it's sometimes a desirable functionality to send some initialization data when the connection is initially opened. Fore example to submit feature set supported by client (like compression algorithms supported or client version). As these persistent sockets are managed by PHP it'd be nice to have some function which could be used to assign user data to given socket. This user data would reset when php backend calls connect C function. Or at least some function which would report bytes received and send on $s. This way user can detect if he got new or already estabilished connection in $s. Test script: --------------- $errno = $errstr = 0; $opt_connect_timeout = 5; $s = pfsockopen('127.0.0.1', '80', $errno, $errstr, $opt_connect_timeout); Expected result: ---------------- Being able to write something like this $errno = $errstr = 0; $opt_connect_timeout = 5; $s = pfsockopen('127.0.0.1', '80', $errno, $errstr, $opt_connect_timeout); if (get_socket_user_data($s) != 'i') { ... send connection initialization data to server ... set_socket_user_data($s, 'i'); } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79507&edit=1

« previous php.bugs (#226718) next »