The following code can connect to the host successfully on iOS Simulator. But the code fails to connect on an iOS device. I has checked the WLAN and Cellular Data are both allowed for the app clip.
I also try NSURLSession to access to a web site. NSURLSession is successful to get the data on both iOS simulator and iOS devices.
Do we allow to use socket streams in App Clips?
Xcode Version 12.0 beta (12A6159)
iOS 14 Beta: 14.0
But the code fails to connect on
Console output:
I also try NSURLSession to access to a web site. NSURLSession is successful to get the data on both iOS simulator and iOS devices.
Do we allow to use socket streams in App Clips?
Xcode Version 12.0 beta (12A6159)
iOS 14 Beta: 14.0
But the code fails to connect on
Code Block Objective-C CFReadStreamRef readStream; CFWriteStreamRef writeStream; //create socket connection CFStreamCreatePairWithSocketToHost(NULL, (bridge CFStringRef)@"www.baidu.com", 443, &readStream, &writeStream); NSInputStream* inputStream = (bridge_transfer NSInputStream*)readStream; NSOutputStream* outputStream = (__bridge_transfer NSOutputStream*)writeStream; [inputStream setProperty:NSStreamSocketSecurityLevelNegotiatedSSL forKey:NSStreamSocketSecurityLevelKey]; // and open the streams [inputStream open]; [outputStream open];
Console output:
Code Block [connection] nw_socket_connect [C1.1:1] connectx(5, [srcif=0, srcaddr=<NULL>, dstaddr=61.135.169.121:443], SAE_ASSOCID_ANY, 0, NULL, 0, NULL, SAE_CONNID_ANY) failed: [65: No route to host] [connection] nw_socket_connect [C1.1:1] connectx failed (fd 5) [65: No route to host] [] nw_socket_connect connectx failed [65: No route to host] [connection] nw_socket_connect [C1.2:1] connectx(5, [srcif=0, srcaddr=<NULL>, dstaddr=61.135.169.125:443], SAE_ASSOCID_ANY, 0, NULL, 0, NULL, SAE_CONNID_ANY) failed: [65: No route to host] [connection] nw_socket_connect [C1.2:1] connectx failed (fd 5) [65: No route to host] [] nw_socket_connect connectx failed [65: No route to host] [connection] nw_connection_get_connected_socket [C1] Client called nw_connection_get_connected_socket on unconnected nw_connection TCP Conn 0x280200370 Failed : error 0:65 [65]