php - Possible to "que" fsockopen? Multiple TCP Sockets -


i've got script creates tcp socket via fsockopen() once per loop. everytime opens connection, entire php script pauses until has been established.

i'm wanting go down path of running 5 simultaneous sockets can speed script.

is there way can "que" fsockopen connection? ideally, pseudo code.

$opensocketcount = 0;

while (1) {      if($opensocketcount < 5) {         for($i=1;$i<6;$i++) {             $sockets[$i] = fsockopen("127.0.0.1",80);             $opensocketcount++;         }     }      //check see if socket connection has been established     for($i=1;$i<6;$i++) {         if ( has_socket_been_established($sockets[$i]) ) {             //post data.             $opensocketcount -= 1;             socket_close($sockets[$i]);             $sockets[$i] = null;         }     }  } 

php not asynchronus. means pauses until connection has been established. there approaches out there using shell scripts or curl multi-thread php not perfect solutions.

if use in frontend go ajax, since asynchronus , call script "socket.php?con=1" etc. in php script have array ip's , connect them value. works if have in frontend. backend approach have use sonething node.js


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -