public function listenAddress($address) { if ($this->factory === null) { $this->factory = new RawFactory(); } $this->socket = $this->factory->createServer($address); if ($this->socket->getType() !== SOCK_STREAM) { $this->socket->close(); throw new Exception('Not a stream address scheme'); } $this->socket->setBlocking(false); $that = $this; $socket = $this->socket; $this->loop->addReadStream($this->socket->getResource(), function () use($socket, $that) { $clientSocket = $socket->accept(); $that->handleConnection($clientSocket); }); }