Home

finding out our own ip

Updated:
Created:
pys60

How to find out the mobile phones ip when using normal the normal socket module ( and not bt_socket)

import socket
aps = [ap['name'] for ap in socket.access_points()]
aps.sort()
apid = appuifw.popup_menu(aps,u'select access point')
socket.set_default_access_point(aps[apid])
#one time socket, for just finding out our ip
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#anonymity issue here
s.connect(('www.google.com',80))
ip = s.getsockname()[0]