×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jun 2009
    Posts
    2

    try to send string via W-LAN

    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
    Last edited by schedlik; 2009-08-11 at 13:11.

  2. #2
    Super Contributor
    Join Date
    Nov 2007
    Location
    Sertaozinho/Brazil
    Posts
    768

    Re: try to send string via W-LAN

    Hi

    Try to use makefile() as well for phone that is sending the message and use flush() method after write(). This will force any pending bytes in this phone to be sent.

  3. #3
    Registered User
    Join Date
    Jun 2009
    Posts
    2

    Re: try to send string via W-LAN

    hey
    i tried to do it with the makefile() argument, but there's still a delay of seconds / minutes before i can access the received data!
    Last edited by schedlik; 2009-08-17 at 09:56. Reason: *edit: problem solved, the access point was responsible for the delay!

Similar Threads

  1. how to get sub string of a long string in j2me
    By mindIt in forum Mobile Java General
    Replies: 5
    Last Post: 2009-07-04, 10:05
  2. C++ 學習程序2
    By hanwen813 in forum [Archived] Other Programming Discussion 关于其他编程技术的讨论
    Replies: 32
    Last Post: 2009-04-02, 09:10
  3. Send string from mobile to PC
    By jprogyog in forum Bluetooth Technology
    Replies: 1
    Last Post: 2008-12-18, 07:28
  4. Send SMS Problem. Cannot Get SMSC Address. Due to Strange SIM Card?
    By cksong in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2007-07-02, 16:13
  5. Send string from phone to hyperterminal via BT
    By msalline in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2004-08-03, 06:27

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •