WEB开发网
开发学院手机开发Symbian 开发 手动关闭一个Symbian GPRS连接 阅读

手动关闭一个Symbian GPRS连接

 2010-08-30 00:07:00 来源:WEB开发网   
核心提示:下面的代码片段显示了如何手动停止激活的GPRS连接,对于我们使用PyS60开发网络应用来说,手动关闭一个Symbian GPRS连接,这是一个非常有用的代码段,socket模块的接入点(access_point)对象主要有三个功能:我们可以知道手机的IP地址,我们可以启动GPRS连接,然后选择一个默认的接入点

下面的代码片段显示了如何手动停止激活的GPRS连接。对于我们使用PyS60开发网络应用来说,这是一个非常有用的代码段。socket模块的接入点(access_point)对象主要有三个功能:

我们可以知道手机的IP地址。

我们可以启动GPRS连接,然后选择一个默认的接入点。

我们可以手动停止或断开GPRS的一个活跃连接。此函数的代码如下:

Python代码

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

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

Tags:手动 关闭 一个

编辑录入:coldstar [复制链接] [打 印]
赞助商链接