i use while for socket_read PHP: public function onEnable(){ Server::getInstance()->getScheduler()->scheduleRepeatingTask(new ParticleTask($this), 1); //Server::getInstance()->getScheduler()->scheduleRepeatingTask(new Sign($this), 100); Server::getInstance()->getScheduler()->scheduleRepeatingTask(new Update($this), 20); Server::getInstance()->getPluginManager()->registerEvents($this, $this); $workerB = new WorkerThread($this->src,$this->dst); $workerB->run(); } class while PHP: class WorkerThread { public function __construct($src, $dst) { $this->src = $src; $this->dst = $dst; } function run() { while(true) { while (($bytes = socket_read($this->src, 1024, PHP_BINARY_READ)) != "") { echo "running... \n"; echo($this->dst. $bytes. 1024); socket_write($this->dst, $bytes, 1024); } } }} and not responding Help guide socket on plugin pls
now work Thank you all for replying PHP: <?phpnamespace ac;use pocketmine\Thread;use pocketmine\utils\Binary;class WorkerThread extends Thread{ public function __construct() { error_reporting(0); set_time_limit(0); $host = "127.0.0.1"; $port = 1234; $this->socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n"); $result = socket_bind($this->socket, $host, $port) or die("Could not bind to socket\n"); $result = socket_listen($this->socket) or die("Could not set up socket listener\n"); echo "Waiting for connections... \n"; $this->start(); } public function run() { while (true) { if(($newc = socket_accept($this->socket)) !== false) { echo "Client $newc has connected\n"; $this->clients[$newc] = $newc; } else { echo "w"; } if(count($this->clients) > 0) { foreach($this->clients as $c) { if(($bytes = socket_read($c, 1024, PHP_BINARY_READ)) != "") { echo($bytes."\n"); socket_close($c); unset($this->clients[$c]); } } } } } public function getThreadName() { }}