-
Notifications
You must be signed in to change notification settings - Fork 369
Open
Description
is the example testwebsock.php multi threaded ?
you need the pthread posix dll for php on windows in order to enable threads ?
I don't think so because it should have
extends Thread
client->start()
client->join() to wait for thread exit if needed
such as this pthread example
<?php
/*
* Please don't use resources, it's dangerous ...
*/
class Test extends Thread {
public $stop = false;
public function __construct($socket){
$this->socket = $socket;
}
public function run(){
while(++$clients < 10 &&
($client = socket_accept($this->socket))){
printf("Accept in %lu\n", $this->getThreadId());
var_dump($client);
var_dump($this->socket);
socket_close($client);
}
}
}
$workers = array();
$sock = socket_create_listen($argv[1]);
if ($sock) {
while(++$worker<5){
$workers[$worker] = new Test($sock);
$workers[$worker]->start();
}
printf("%d threads waiting on port %d\n", count($workers), $argv[1]);
}
foreach ($workers as $thread)
$thread->join();
?>
possibily could you post a multi thread version of testwebsock.php please
I think that example is single threaded, and handles receive in process() for each user, round robin, I enclose an example where also the transmit in tick() is called round robin for each user with per client requested data from a mongo db in case you wish to make a similar multiple client example please
Metadata
Metadata
Assignees
Labels
No labels