Python Server Socket on Mobile Device?

It may sound like a dumb question. But I know that python can run on Android and Ios. And I know that client and server sockets are what make up the entire internet and should therefore be compatible on every device. But I just want to make sure of something:

Say I made a SERVER socket program with python on windows. If I turned this program into a .apk (android executable) or whatever iphones executable is called, would it run on the portable device? Are there any restrictions? Can only a client be run on a portable device? Or can a server be as well? Ive never really heard of running a server from a cell phone before and this causes me to wonder. I just have a feeling that it cant be THAT simple for some reason because nothing ever is…

A server on a mobile phone would require the python script to run as permanent service, usual apps are terminated by the OS if necessary or after longer idle (to improve memory utilization and battery life).

Can’t see a reason why socket connections shouldn’t work in general, as long as no firewall restricts access. HTTP traffic on port 80 should always work whatsoever.

What would I have to do make the app a permanent service? couldn’t I just create a loop?

You better refer to the android docs:
http://developer.android.com/reference/android/app/Service.html

See life cycle paragraph here:
http://developer.android.com/reference/android/app/Activity.html

And here’s more about process management:

thanks man

From a quick check, both Android and iOS support listening sockets. You already have documents for Android Services and iOS has a feature that works in a similar manner. The only question would be how the Python runtime interacts with Android and iOS. Normally you would write an Android app directly in Java and have direct access to the Android API calls for creating services. The same for iOS if you create the app directly in Objective-C then you have access to the OS API calls. I’m not sure if the Python runtimes for those platforms support that kind of interaction.