Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I activate the cellular radio in iOS since bsd-sockets doesn't activate it automatically

I intend to write a cross platform library in C which will need to do some networking. I saw that iOS supports sockets but the Apple developer site warns against using POSIX sockets:

In iOS, POSIX networking is discouraged because it does not activate the cellular radio or on-demand VPN. Thus, as a general rule, you should separate the networking code from any common data processing functionality and rewrite the networking code using higher-level APIs.

However it also suggests that POSIX sockets are a good option for something cross platform. Since POSIX sockets don't automatically activate the cellular radio I'll need to do that myself right? Is there a better way to do this than simply opening a connection with a higher-level api and closing the connection before hand?

like image 419
Fsmv Avatar asked Jul 30 '14 19:07

Fsmv


1 Answers

was attempting the same thing and although the docs say that lower level APIs will not activate the cellular radio and on-demand VPN, turns out its not entirely true for TCP connections.

In the case of UDP, this holds true and your UDP packets don't get sent most of the time. To solve this, just open up a listening socket for TCP using the lower level APIs and this will activate the cellular radio or on-demand VPN and close the socket once you are done.

For TCP, you can use the low-level APIs for server side code on iOS devices and this DOES activate the cellular radio or on-demand VPN but for client side code on iOS devices, it is preferable to use higher level APIs that have been provided. Either way, the radio is active and you don't have to worry about packets not being sent.

BTW, this is what I am currently doing.

like image 188
Shehzan Avatar answered Nov 02 '22 23:11

Shehzan