×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    20

    Anyone using PyS60 2.0.0 on a Symbian S60 5th Edition

    Hi PyS60 fans,

    I'm trying to use PyS60 2.0.0 on a Nokia 5800 XpressMusic, and I have trouble doing network connections.

    I'm doing something like:

    Code:
    import btsocket
    apid = btsocket.select_access_point()
    apo = btsocket.access_point(apid)
    btsocket.set_default_access_point(apo)
    apo.start()
    s = btsocket.socket(btsocket.AF_INET, btsocket.SOCK_STREAM)
    s.connect(('www.python.org',80))
    s.send('GET /\n')
    answer = s.recv(1000)
    s.close()
    del s
    apo.stop()
    del apo
    print answer
    And I always receive:

    Code:
    Traceback (most recent call last):
      File "<console>", line 1, in <module>
      File "c:\resource\python25\python25.zip\btsocket.py", line 340, in recv
        data=self._sock.recv(n, f, cb)
    error: (32, 'Broken pipe')
    on the line "answer = s.recv(1000)".

    This works fine on a Symbian S60 3rd Edition Feature Pack 2 (a Nokia E55).

    So, my question, is someone using PyS60 2.0.0 on a Symbian S60 5th Edition ? And are you using network stuff on it ?

    Thanks in advance for any answer.

    --
    Olivier

  2. #2
    Regular Contributor
    Join Date
    May 2007
    Posts
    75

    Re: Anyone using PyS60 2.0.0 on a Symbian S60 5th Edition

    Well, if I change one line a bit it works on my N97 (note the extra \n):

    Code:
    s.send('GET /\n\n')
    Without the '\n' (which is required per HTTP spec, if I remember correctly) I get either no data or a broken pipe. I think the broken pipe may be caused by the server giving up on the HTTP request.

    But wouldn't you be better off using httplib, instead of trying to implement the HTTP protocol yourself? There are a few issues with that, one major is that DNS resolution often fails and leads to 'invalid argument' errors. This works (if I did not make any typos, that is):

    Code:
    import httplib
    conn = httplib.HTTPConnection('82.94.164.162')
    conn.request("GET", '/')
    r1 = conn.getresponse()
    print r1.status, r1.reason
    data1 = r1.read()
    print data1
    But replacing '82.94.164.162' with 'www.python.org' often causes an invalid argument error, the socket module (used by httplib) is unable to resolve the host name:
    Code:
    socket.gethostbyname('www.python.org')
    fails.

    Interestingly the following code usually does give a correct result:
    Code:
    btsocket.gethostbyname('www.python.org')
    And combined:
    Code:
    import httplib
    import btsocket
    conn = httplib.HTTPConnection(btsocket.gethostbyname('www.python.org'))
    conn.request("GET", '/')
    r1 = conn.getresponse()
    print r1.status, r1.reason
    data1 = r1.read()
    print data1
    Be aware that for this code to work you may have to set the default access point for both the socket and the btsocket module ...

  3. #3
    Registered User
    Join Date
    Jul 2008
    Posts
    20

    Re: Anyone using PyS60 2.0.0 on a Symbian S60 5th Edition

    Hi,

    first, thanks for testing this. I think I have found a solution for my problem:

    Quote Originally Posted by mwibbels View Post
    Be aware that for this code to work you may have to set the default access point for both the socket and the btsocket module ...
    Seems it's my problem with the XpressMusic. I can connect if I setup with something like:

    Code:
    import btsocket
    apid = btsocket.select_access_point()
    apo = btsocket.access_point(apid)
    btsocket.set_default_access_point(apo)
    
    import socket
    btsocket.set_default_access_point(u'MY ACCESS POINT NAME')
    Great
    Strange, but great.
    Before, I wasn't doing both btsocket and socket connection. Just btsocket.

    Thanks a lot for your help, and have a nice day.

    --
    Olivier

  4. #4
    Registered User
    Join Date
    Jul 2008
    Posts
    20

    Re: Anyone using PyS60 2.0.0 on a Symbian S60 5th Edition

    Hi all,

    the trick to use set_default_access_point() with both btsocket and socket works, good.

    I have now two remaining bugs around this:

    • stop the connection. I don't know how to stop the access point. apo.stop() don't works, and even after some hours, the access point is still connected. The only solution I have found is to stop via the connection manager application.
    • python crash when doing btsocket.set_default_access_point(u'AP') more than one time.

    Do you have some tips for this points too ?

    Thanks in advance for your help.

    --
    Olivier

Similar Threads

  1. [moved] Symbian^3 on S60 5th Edition devices?
    By djbanzo1 in forum Symbian
    Replies: 3
    Last Post: 2010-04-28, 15:33
  2. Replies: 9
    Last Post: 2009-12-16, 16:01
  3. opengl for symbian s60 5th edition
    By Gargo in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 6
    Last Post: 2009-07-31, 20:01
  4. Replies: 2
    Last Post: 2009-07-07, 09:13

Posting Permissions

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