×

Discussion Board

Results 1 to 1 of 1

Thread: Socket problem

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    1

    Socket problem

    Hy there!

    I'm working on a wireless file-transfer program over bluetooth.
    Its rather hard to find any dokumentation about this topic, but i at least
    made it to resolve bluetooth devices in range and establish a connection.
    the problem i now have is that every time i try to transfer files (obex format)
    the program crashes and displays socket.error number 13: permission denied.
    after I googled this error about 3 hours, i gave up, i couldnt find anything.
    then i tried to use the RFCOMM class to transfer normal streams, but again
    i got an error. this time it was: socket.error 0: error.
    googling again, the same result as above: none.
    i have also searched this forum, but couldnt find anything that fits.



    The code for obex file transfer(client):

    def cl_sv_func(target): # target = ('adress', port)
    # make socket
    mySocket = socket(AF_BT, SOCK_STREAM)

    # if there is a server given, play client
    if isNumberType(target[1]):
    mySocket.connect(target)
    # IO stuff here
    send_path = u"c:\\simple_send.txt"
    receive_path = u"c:\\"

    f=open(send_path, 'w')
    f.write("hello")
    f.close

    bt_obex_send_file(target[0], target[1], send_path)
    bt_obex_receive(mySocket, receive_path)
    # close socket
    mySocket.close
    # ... else do the server part


    The code for obex file transfer(server):

    # mySocket was made bevore, see client
    # get server channel
    port = bt_rfcomm_get_available_server_channel(mySocket._sock)

    # bind socket to port
    mySocket.bind(("", port))

    # advertise service
    bt_advertise_service( u"bla", mySocket._sock, True, OBEX )

    # set security level: authorised
    set_security(mySocket._sock, AUTHOR)

    # listen to socket
    tell("starting listening on Port: " + str(port))
    mySocket.listen(1)
    tell("waiting for connection...")

    # if there is a connection request: accept
    myConnection, adress = mySocket.accept()
    tell("connected to: " + adress + ", " + str(port))

    # IO stuff here
    send_path = u"c:\\simple_send.txt"
    receive_path = u"c:\\"

    f=open(send_path, 'w')
    f.write("hello you")
    f.close

    bt_obex_receive(mySocket, receive_path)
    bt_obex_send_file(adress, port, send_path)

    # close socket
    mySocket.close


    the code is partly from this forum, partly i made it up by myself, but i already found it nearly similar at other
    places, so should work...
    but as soon as the client starts to send: socket error 13: permission denied

    i already tryed to skip the connect() and accept() statements, to see what
    happens, but error was the same...
    then i tried to bind the socket at the client part and set the security to author there too. worked, but did not fix the problem.



    The code for rfcomm stream transfer(client):

    # nearly same code as up, only with rfcom stream "IO"
    def cl_sv_func(target): # target = ('adress', port)
    # make socket
    mySocket = socket(AF_BT, SOCK_STREAM)

    # if there is a server given, play client
    if isNumberType(target[1]):

    mySocket.connect(target)
    tell("connected to: " + target[0] + ", " + str(target[1]))

    blaa = "bla"
    mySocket.send(blaa.replace('\n','\r\n'))
    rec = mySocket.recv(7)
    tell(rec)

    # close socket
    mySocket.close



    The code for rfcomm stream transfer(server):


    # get server channel
    port = bt_rfcomm_get_available_server_channel(mySocket._sock)

    # bind socket to port
    mySocket.bind(("", port))

    # advertise service
    bt_advertise_service( u"bla", mySocket._sock, True, RFCOMM )

    # set security level: authorised
    set_security(mySocket._sock, AUTHOR)

    # listen to socket
    tell("starting listening on Port: " + str(port))
    mySocket.listen(1)
    tell("waiting for connection...")

    # if there is a connection request: accept
    myConnection, adress = mySocket.accept()
    tell("connected to: " + adress + ", " + str(port))

    # IO stuff here
    blaa = "workerr"

    rec = mySocket.recv(3)
    mySocket.send(blaa.replace('\n','\r\n'))
    tell(rec)

    # close socket
    mySocket.close

    ... the code is partly from this forum, partly from the nokia simple_bluetooth
    example, so should work. but again, as soon as the client phone is trying to receive: socket error 0.


    as said: connection works, but as soon i try to send/receive something:
    *BOINK*

    Here are the phones I'm using:

    Nokia 3230, pythonForSer60 2nEdFP2 => plays the client part
    Nokia Ngage, pythonForSer60 2nEdFP2 => plays server part



    If anyone got a clue, why i cant transfer anything, please respond!
    you guys are my last hope, i dont want to give up days of work...
    Last edited by defragger; 2005-08-25 at 08:22.

Similar Threads

  1. socket sending per packet problem
    By Rx-lee in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2005-04-13, 13:06
  2. socket server application using Series 60 SDK
    By irohit in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2004-09-16, 05:27
  3. socket connection problem
    By bhatti81 in forum Mobile Java General
    Replies: 2
    Last Post: 2003-10-08, 14:43
  4. Problem Socket in 7650 Phone
    By yaney in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2002-11-06, 05:37
  5. TCP/IP socket connection problem
    By ArunP in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2002-09-19, 10:09

Posting Permissions

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