title: Reading error from Apple enhanced push notification with PHP
body: <p>Im trying to trigger an error so I can build in error logging for APNS. Therefore Im sending a too large payload to the server. But I get no error.</p>
  
  <p><strong>Code:</strong></p>
  
  <p>Connecting:</p>
  
  <pre><code>$streamContext = stream_context_create();
  stream_context_set_option($streamContext, 'ssl', 'local_cert', $this-&gt;_sslPem);
  stream_context_set_option($streamContext, 'ssl', 'passphrase', "");
  
  $this-&gt;_apnsConnection = stream_socket_client("ssl://" . Config::$apns['host'] . ":" . Config::$apns['port'], $error, $errorString, $timeout, STREAM_CLIENT_CONNECT, $streamContext);
  
  if ($this-&gt;_apnsConnection) {
      stream_set_blocking($this-&gt;_apnsConnection, 0);
  }
  </code></pre>
  
  <p>Sending notification:</p>
  
  <pre><code>$this-&gt;_log("Sending notification to device token '$deviceToken'");
  
  $identifiers = array();
  for ($i = 0; $i &lt; 4; $i++) {
      $identifiers[$i] = rand(1, 100);
  }
  
  $apnsMessage = chr(1) . chr($identifiers[0]) . chr($identifiers[1]) . chr($identifiers[2]) . chr($identifiers[3]) . pack('N', time() + 3600) 
      . chr(0) . chr(32) . pack('H*', str_replace(' ', '', $deviceToken)) . chr(0) . chr(strlen($message)) . $message;
  $bytes = fwrite($this-&gt;_apnsConnection, $apnsMessage);
  
  $this-&gt;_log("bytes written: $bytes");
  
  $this-&gt;_log("Fetching response");
  $response = fread($this-&gt;_apnsConnection, 6);
  
  $this-&gt;_log("Strlen: " . strlen($response));
  
  if ($response === false || strlen($response) != 6) {
  
      $this-&gt;_log("No response...");
  } else {
  
      $responseArray = unpack('Ccommand/CstatusCode/Nidentifier', $response);
      $this-&gt;_log("Response!");
      $this-&gt;_log($responseArray);
  }
  </code></pre>
  
  <p><strong>Output:</strong></p>
  
  <pre><code>2011-07-12 16:25:55: Sending notification to device token 'XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX'
  2011-07-12 16:25:55: bytes written: 438
  2011-07-12 16:25:55: Fetching response
  2011-07-12 16:25:55: Strlen: 0
  2011-07-12 16:25:55: No response...
  </code></pre>