Aerys\Server::onAcceptable PHP Method

onAcceptable() private method

private onAcceptable ( string $watcherId, $server )
$watcherId string
    private function onAcceptable(string $watcherId, $server)
    {
        if (!($client = @\stream_socket_accept($server, $timeout = 0, $peerName))) {
            return;
        }
        $portStartPos = strrpos($peerName, ":");
        $ip = substr($peerName, 0, $portStartPos);
        $port = substr($peerName, $portStartPos + 1);
        $net = @\inet_pton($ip);
        if (isset($net[4])) {
            $perIP =& $this->clientsPerIP[substr($net, 0, 7)];
        } else {
            $perIP =& $this->clientsPerIP[$net];
        }
        if ($this->clientCount++ === $this->options->maxConnections | $perIP++ === $this->options->connectionsPerIP) {
            assert($this->logDebug("client denied: too many existing connections"));
            $this->clientCount--;
            $perIP--;
            @fclose($client);
            return;
        }
        \assert($this->logDebug("accept {$peerName}"));
        \stream_set_blocking($client, false);
        $contextOptions = \stream_context_get_options($client);
        if (isset($contextOptions["ssl"])) {
            $clientId = (int) $client;
            $watcherId = \Amp\onReadable($client, $this->negotiateCrypto, $options = ["cb_data" => [$ip, $port]]);
            $this->pendingTlsStreams[$clientId] = [$watcherId, $client];
        } else {
            $this->importClient($client, $ip, $port);
        }
    }