protected function createClient($endpoint, $options = [])
{
$context = [];
$context['socket'] = ['connect' => $endpoint];
$context = stream_context_create($context);
// Error reporting suppressed since stream_socket_client() emits an E_WARNING on failure.
$socket = @stream_socket_client($endpoint, $errno, $errstr, null, STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT, $context);
if (!$socket || $errno) {
throw new LogicException(sprintf('Could not connect socket [%s] because of error [%d; %s]', $endpoint, $errno, $errstr));
}
return $socket;
}