/** * @return self */ protected function workOnMasterSocket() { if (@socket_recvfrom($this->masterSocket, $buffer, $this->bufferLength, MSG_DONTWAIT, $src, $spt)) { $client = $this->getClientByIpAndPort($src, $spt); if (!$client instanceof ServerClient) { $client = new ServerClient(); $client->setHost($src); $client->setPort($spt); $this->clients[$client->getId()] = $client; $this->onConnect($client); } $client->setAttribute('timeout', microtime(true) + $this->timeoutSeconds + $this->timeoutUSeconds / 1000); $this->onIncoming($client, $buffer); } return $this; }
/** * @return self */ protected function workOnMasterSocket() { $socket = @socket_accept($this->masterSocket); if (is_resource($socket)) { @socket_getpeername($socket, $src, $spt); $client = new ServerClient(); $client->setSocket($socket); $client->setHost($src); $client->setPort($spt); $this->clients[$client->getId()] = $client; $this->onConnect($client); } return $this; }