I have an application that is a socket server application. I want to use it on iOS (not app store). I have tried to bind my C++ program's native socket the way it is mentioned in the apple documentation, however nothing is happening.
The C++ program is using signal/slots with QTcpServer. I have some code like this:
driver = ProxyDriver::getInstance(5150);
NSLog(@"Socket descriptor %i" , driver->socketDescriptor());
CFReadStreamRef readStream;
CFWriteStreamRef writeStream;
CFStreamCreatePairWithSocket (kCFAllocatorDefault, driver->socketDescriptor(), &readStream, &writeStream);
CFReadStreamSetProperty(readStream, kCFStreamNetworkServiceType, kCFStreamNetworkServiceTypeVoIP);
CFWriteStreamSetProperty(writeStream, kCFStreamNetworkServiceType, kCFStreamNetworkServiceTypeVoIP);
driver->socketDescriptor() returns the int that is my QTcpServer's listening socket.
The code I posted is in my app delegates "applicationDidEnterBackground" and I have enabled "Voice over IP" in my .plist file.
However, it seems weird - if I do a netcat to the IP address of the listening socket while the application is in the background - it does not wake up and call the "accept connections" slot that I have defined in my Qt app. However, as soon as I bring the app back to the foreground, the slot is called.
What am I doing wrong? Do I already need to have a socket connected before I can create my stream pair?
Yes the socket need to be connected to server before the App going to background, otherwise iOS won't keep it "alive"
You can not use a listening socket for the VOIP Background functionality.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.