| ID | ... | Creation date | 23 August 2008 |
| Platform | S60 1st Edition, S60 2nd Edition, S60 3rd Edition | Tested on devices | Nokia N95, Nokia E90 |
| Category | Python | Subcategory | Connectivity |
| Keywords (APIs, classes, methods, functions): socket |
The small code snippet below shows how to stop an active GPRS connection manually. This is a very useful code snippet when we are developing applications related to networking in PyS60. The access point (access_point) object of the socket module mainly serves three purposes:
#imports the Module (Python 1.4.5)
import socket
from appuifw import *
def sel_access_point():
""" Select and return the access point or None (error)
"""
aps = socket.access_points()
if not aps:
note(u"No access points available","error")
return None
ap_labels = map(lambda x: x['name'], aps)
item = popup_menu(ap_labels,u"Access points:")
if item is None:
return None
apo = socket.access_point(aps[item]['iapid'])
return apo
ap = sel_access_point()
if ap:
ap.start() # start an GPRS connection
print "IP:", ap.ip()
ap.stop() # stops an GPRS connection
No related wiki articles found