title: iOS Unable to "Configure one of the app’s sockets for VoIP usage" for background mode
body: <p>I am trying to set up my app to listen to a tcp-socket even when the app is suspended. I set the voip-background mode in the Info.plist as described in the apple documentation. Now I am stuck where is says: "Configure one of the app’s sockets for VoIP usage.". I am trying to do this with the CFReadStreamSetProperty() methods but the point is how I create the sockets. The creation of the socket is done via the standard C-Library like this:</p>
  
  <pre><code>int mySock = socket(AF_INET, SOCK_STREAM, 0);
  </code></pre>
  
  <p>This is done inside a .cpp file within an existing library. This is what I have tried to configure the socket for VoIP usage:</p>
  
  <pre><code>CFStreamCreatePairWithSocket(kCFAllocatorDefault, sock, &amp;readStream, &amp;writeStream);
  if(readStream &amp;&amp; writeStream)
  {
     CFReadStreamSetProperty(readStream, kCFStreamNetworkServiceType, kCFStreamNetworkServiceTypeVoIP);
     CFWriteStreamSetProperty(writeStream, kCFStreamNetworkServiceType, kCFStreamNetworkServiceTypeVoIP);
  }
  </code></pre>
  
  <p>When I step through it it is looking good but unfortunately it does not work. Whenever the app is going from foreground to background/suspended the connection gets lost and any input from the server is ignored. I have no clue if the configuration of the socket can be done like this at all and can not find an answer to it.</p>