| Reply | « Previous Thread | Next Thread » |
|
hi,
I am using the following code to send and receive data from a server using TCP / IP, to send and receive data using two different threads, when the application tries to receive data on line con.recv (8192) comes out of the application and shows a KERN-EXEC 3. Code:
import socket
import thread
.
.
SERVER = ("localhost", 80)
con = None
class ConPrueba:
def send(self):
global con
try:
con = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
con.connect((SERVER))
self.con.send("datas")
except:
print "don't send"
def receiver(self):
e32.ao_sleep(20)
timeout=2
con.setblocking(0)
total_data=[];data='';begin=time.time()
while 1:
#if you got some data, then break after wait sec
if total_data and time.time()-begin>timeout:
break
#if you got no data at all, wait a little longer
elif time.time()-begin>timeout*2:
break
try:
data=con.recv(8192)
if data:
total_data.append(data)
begin=time.time()
else:
time.sleep(0.1)
except Exception,ex:
print ex
p = ConPrueba()
thread.start_new_thread(p.send,())
thread.start_new_thread(p.receiver,())
|
|
Join Date: Nov 2007
Posts: 319
Location: Sertaozinho/Brazil
marcelobarrosalmeida
Offline
Forum Nokia Champion
|
|
|
Hi (again) !
I had several problems using multi-thread and sockets in versions before 1.9.0. To be honest, I was trying to solve them when 1.9.0 was released. So, with 1.9.0 I could use threading module and things became much easier. I had just a small problem related to socket library used in console but it seems to be solved in 1.9.1. From the changelog: Quote:
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 |
|---|---|---|---|---|
| Listbox in dialog gives 'Kern Exec 3' on mobile | hansapariya | Symbian User Interface | 1 | 2009-07-24 08:01 |
| KERN EXEC 3 on device not on Epoc | Kavit Patel | General Symbian C++ | 4 | 2008-11-21 16:02 |
| KERN EXEC 3 ERROR | sanjayks84 | Symbian User Interface | 3 | 2008-05-28 10:13 |
| KERN EXEC 3 while deleting listbox | hansapariya | General Symbian C++ | 4 | 2008-03-29 10:09 |
| why kern exec 3 on CopyFile? | flicker82 | General Symbian C++ | 2 | 2005-05-16 03:25 |