private function openConnectionAPNS($ctx)
    {
        $fp = false;

        // Open a connection to the APNS server
        try {
            $fp = stream_socket_client(
                $this->url,
                $err,
                $errstr,
                60,
                STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT,
                $ctx
            );

            stream_set_blocking($fp, 0);

            if (!$fp) {
                $response = ['success' => false, 'error' => "Failed to connect: $err $errstr" . PHP_EOL];

                $this->setFeedback(json_decode(json_encode($response)));

            }

        } catch (\Exception $e) {
            //if stream socket can't be established, try again
            if ($this->canRetry()) {
                return $this->openConnectionAPNS($ctx);
            }

            $response = ['success' => false, 'error' => 'Connection problem: ' . $e->getMessage() . PHP_EOL];
            $this->setFeedback(json_decode(json_encode($response)));

        } finally {
            $this->resetAttempts();
            return $fp;
        }
    }
private function openConnectionAPNS($ctx)
    {
        $fp = false;

        // Open a connection to the APNS server
        try {
            $fp = stream_socket_client(
                $this->url,
                $err,
                $errstr,
                60,
                STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT,
                $ctx
            );

            stream_set_blocking($fp, 0);

            if (!$fp) {
                $response = ['success' => false, 'error' => "Failed to connect: $err $errstr" . PHP_EOL];

                $this->setFeedback(json_decode(json_encode($response)));

            }

        } catch (\Exception $e) {
            //if stream socket can't be established, try again
            if ($this->canRetry()) {
                return $this->openConnectionAPNS($ctx);
            }

            $response = ['success' => false, 'error' => 'Connection problem: ' . $e->getMessage() . PHP_EOL];
            $this->setFeedback(json_decode(json_encode($response)));

        } finally {
            $this->resetAttempts();
            return $fp;
        }
    }
private function openConnectionAPNS ( $ ctx ) { $ fp = false ; // Open a connection to the APNS server try { $ fp = stream_socket_client ( $ this -> url , $ err , $ errstr , 60 , STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT , $ ctx ) ; stream_set_blocking ( $ fp , 0 ) ; if ( ! $ fp ) { $ response = [ 'success' => false , 'error' => "Failed to connect: $err $errstr" . PHP_EOL ] ; $ this -> setFeedback ( json_decode ( json_encode ( $ response ) ) ) ; } } catch ( \ Exception $ e ) { //if stream socket can't be established, try again if ( $ this -> canRetry ( ) ) { return $ this -> openConnectionAPNS ( $ ctx ) ; } $ response = [ 'success' => false , 'error' => 'Connection problem: ' . $ e -> getMessage ( ) . PHP_EOL ] ; $ this -> setFeedback ( json_decode ( json_encode ( $ response ) ) ) ; } finally { $ this -> resetAttempts ( ) ; return $ fp ; } }
Create the connection to APNS server
If some error, the error is stored in class feedback property.
IF OKAY, return connection

@return bool|resource
Create the connection to APNS server If some error the error is stored in class feedback property . IF OKAY return connection