8.5. Pushing Data to a Phone

The socket module provided by PyS60 closely resembles its sibling on the server side. The module contains functions for listening to a port for incoming TCP connections (functions bind(), listen() and accept()). With these functions you can create a simple TCP server and run it on a phone as you would do on a PC (Figure 8.5).

8.5.1. Drawbacks with using a Phone as a Server

However, three issues tend to make life difficult for phone-based servers:

  • Unless the phone stays in one location all the time, its IP address is likely to change when the phone moves from one network to another. Clients must be kept updated on the mobile server's most recent IP address; fortunately, this is possible with several methods.

  • Typically, operators do not allow inbound connections over the GSM or 3G network to the phone, because of security and other reasons.

    Figure 8-5. Pushing data to a phone
  • Even though server-side sockets are supported by PyS60, there is only limited support for handling multiple simultaneous connections on the phone side. Thus, scaling up performance of a server-on-a-phone is not an easy task.

Within a small, local WiFi network these issues might not be issues at all. Thus, it is possible to perform local experimentation on phone-side server software. However, beware that this aspect of PyS60 has received less testing than other, more widely used modules ...

Get Mobile Python: Rapid Prototyping of Applications on the Mobile Platform now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.