I couldn't use that socketObj.disconnect() call. It raised an error and when I tried to look up disconnect in the docs I couldn't find it. The following code snippet successfully creates a service that a PDA connects to and then ends the service. It restarts another service but the PDA crashes because the PDA cannot handle the situation where the phone closes the connection. I'll continue to test this code, but I think it is functional.
Code:
from socket import *
import appuifw
import e32
def Connect():
server_socket = socket (AF_BT, SOCK_STREAM)
p = bt_rfcomm_get_available_server_channel(server_socket)
server_socket.bind(("",p))
print "bind done"
server_socket.listen(1)
bt_advertise_service("jurgen", server_socket, True, RFCOMM)
set_security(server_socket, AUTH)
print "I am listening"
(sock, peer_addr) = server_socket.accept()
print "connection from %s" %peer_addr
sock.send("what")
e32.ao_sleep(1)
return sock
foo = Connect()
print "out of connect()"
foo.close()
print "sock closed"
#foo.disconnect()
print "sock disconnected"
Connect()