| Reply | « Previous Thread | Next Thread » |
|
Hi to all!
Can somebody help me? I have created an application that connect to web, print value from a web page end then disconnect from the web (the disconnection don't work). I have problem with socket.close() because don't work and i have to close my python app to close connection. Is there a way to close connection without close my app? Thanks and sorry for my english! Code:
import e32
import socket
from dialog import Wait, Progress
from fonts import*
t = e32.Ao_timer()
n = 0
credito = 0
m = 0
def ricevicredito():
apid = 5
ap = socket.access_point(apid)
socket.set_default_access_point(ap)
urlWEB = urllib.urlopen
response = urlWEB('http://xxx').read()
try:
credito = re.search('<td class="xxx" width="">Il tuo credito residuo \xxxx', response).group(1)
except:
credito = 0.0
n = credito
print n
e32.ao_sleep(0)
###############################
# CLOSE SOCKET CONNECTION #
###############################
socket.close() #DON'T WORK
t.after(5, ricevicredito)
|
|
Join Date: Nov 2007
Posts: 317
Location: Sertaozinho/Brazil
marcelobarrosalmeida
Online
Forum Nokia Champion
|
|
Hi impazzito,
You only can close a socket objetct that you have created. In this case, you did not create any socket object but you are calling the socket method "close". So, just do nothing at the end, comment out the line socket.close() In the following case you need an explicit close call: Code:
from socket import * s = socket(AF_INET,SOCK_STREAM) s.connect((ip,port)) # communication goes here, s.send(), s.recv() s.close() Code:
socket.access_point(apid) socket.set_default_access_point(ap) Marcelo Barros Nokia E71, N800, N95 and XM 5800 http://www.croozeus.com http://wordmobi.wordpress.com http://jedizone.wordpress.com |
|
Thanks marcelobarrosalmeida!
I have solved! Now I have another question. Is there a way to "do something when a call is finisched"?? this is my idea: Code:
make a call close the conversation start the programm |
|
Join Date: Nov 2007
Posts: 317
Location: Sertaozinho/Brazil
marcelobarrosalmeida
Online
Forum Nokia Champion
|
|
|
Quote:
![]() If it is a different topic why not open a new thread ? If it is related please try to explain again or put some code. Marcelo Marcelo Barros Nokia E71, N800, N95 and XM 5800 http://www.croozeus.com http://wordmobi.wordpress.com http://jedizone.wordpress.com |
|
Quote:
Code:
import e32
import socket
from dialog import Wait, Progress
from fonts import*
t = e32.Ao_timer()
n = 0
credito = 0
m = 0
def ricevicredito():
apid = 5
ap = socket.access_point(apid)
socket.set_default_access_point(ap)
urlWEB = urllib.urlopen
response = urlWEB('http://xxx').read()
try:
credito = re.search('<td class="xxx" width="">Il tuo credito residuo \xxxx', response).group(1)
except:
credito = 0.0
n = credito
print n
e32.ao_sleep(0)
###############################
# CLOSE SOCKET CONNECTION #
###############################
socket.close() #DON'T WORK
ap.stop() #THIS STOP CONNECTION
t.after(5, ricevicredito)
![]() |
|
Join Date: Nov 2007
Posts: 317
Location: Sertaozinho/Brazil
marcelobarrosalmeida
Online
Forum Nokia Champion
|
|
So, madhacker, this is the same code you put in previous posts, even with same problems (socket.close(), for instance). If you want to open an url and get a result, you may try:
Code:
import urllib
# returns a file like interface
furl = urllib.urlopen("http://your_url_goes_here")
# reading the "file"
contents = furl.read()
# saving the page contents
flocal = open("filename_here.html","wt")
flocal.write(contents)
Code:
import urllib
urllib.urlretrieve("http://your_url_goes_here","filename_here.html")
Marcelo Barros Nokia E71, N800, N95 and XM 5800 http://www.croozeus.com http://wordmobi.wordpress.com http://jedizone.wordpress.com |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| problem in persistant socket connection | poms4symbian | Browsing and Mark-ups | 0 | 2006-01-03 14:23 |
| Explicitly close socket connection | phibo | Mobile Java Networking & Messaging & Security | 1 | 2005-11-25 16:15 |
| Socket problem | defragger | Python | 0 | 2005-08-25 09:16 |
| Symbian socket close bug? | matdodgson | Symbian Networking & Messaging | 2 | 2004-03-26 14:35 |
| close and reconenct of socket | cs_lcmaa | Symbian Networking & Messaging | 2 | 2003-11-13 04:31 |