good afternoon ladies and gentlemen
lets go directly into my problem.
i'm trying to send some string data via WLAN from one N95 8GB to another. both phones are connected using an accesspoint with fixed ip's.
as you can see in the following code, i'm sending increasing numbers.(works fine!)
BUT:
on the client a typical print would look like:
(ip, message for established connection, etc)
1
(some seconds delay)
1234
(some MINUTES delay!!!)
123456
12345678
12345678910
(and so on, new print every 2- 5 seconds)
(if i TURN OFF the server phone in this moment, the output continues with new numbers!
some minutes later socket error 0 "error" is raised.)
on the client phone is this (buggy ?) code. __ (underlines must be seen as tab's)
# testdatei
import e32db #for database operation
import e32 #to know if in emulator
import appuifw #for the query
import time #to get the current time
import os #to delete the database
import sysinfo #to get imei
import math #to calculate distance (radians does not exist)
import graphics #To deal with images
import socket #For bluetooth
import positioning #To get gps data
class test:
_ def __init__(self,sock,adress):
__ self.ad=adress
__ self.sock=sock
__ self.timer=e32.Ao_timer()
__ self.int=0
__ self.buffer=0
__ self.text=u""
_ def func(self):
__ self.timer.cancel()
__ self.text += self.sock.read(5) #also tested with self.text += self.sock.recv(5)
__ print self.text
__ self.timer.after(2,self.func)
apid = socket.select_access_point()
apo = socket.access_point(apid)
apo.start()
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print apo.ip()
ipServer="192.168.100.31"
portServer= 9030
adress=(ipServer,portServer)
s.connect(adress)
obj=s.makefile ("rw")
print u"connected"
myclass=test(obj,adress) #also tested with myclass=test(s,adress)
myclass.func()
the server phone is actually working, using the following code:
import e32db #for database operation
import e32 #to know if in emulator
import appuifw #for the query
import time #to get the current time
import os #to delete the database
import sysinfo #to get imei
import math #to calculate distance (radians does not exist)
import graphics #To deal with images
import socket #For bluetooth, wlan
class test:
_ def __init__(self,connection):
__ self.connection = connection
__ self.timer=e32.Ao_timer()
__ print "class activated"
__ self.int=0
_ def func(self):
__ self.int = self.int +1
__ self.timer.cancel()
__ self.timer.after(1,self.func)
__ self.connection.send(str(self.int))
__ print str(self.int)
apid = socket.select_access_point()
apo = socket.access_point(apid)
apo.start()
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print apo.ip()
ipServer="192.168.100.31"
portServer= 9030
adress=(ipServer,portServer)
s.bind(adress)
s.listen(1)
connection,adress=s.accept()
print u"sock bind"
myclass = test(connection)
myclass.func()
as i think, the data has to be stored somewhere in the client phone, put to recv buffer 'randomly'
am i right?? and HOW can i fix it??
greetings from dortmund, germany
edit:
latest firmware on both phones is installed
python version is 1.4.5

Reply With Quote


