public static function create(string $bootstrap, int $workerCount = null) : ProcessManager { if (Socket::isUnixSocketSupported()) { $url = \sprintf('unix://%s/k1_ipc_%s.sock', \sys_get_temp_dir(), \md5((string) \microtime(true))); } else { $port = Socket::findUnusedPort('tcp', '127.0.0.1'); $url = \sprintf('tcp://127.0.0.1:%u', $port); } $errno = null; $errstr = null; $server = @\stream_socket_server($url, $errno, $errstr, \STREAM_SERVER_BIND | \STREAM_SERVER_LISTEN); if ($server === false) { throw new \RuntimeException(\sprintf('Failed to create IPC server "%s" [%s]: "%s"', $url, $errno, $errstr)); } return new static($url, $server, $bootstrap, $workerCount); }