I
I
Ilya2015-12-26 18:01:01
Python
Ilya, 2015-12-26 18:01:01

Why won't the bluetooth.socket connection close?

I do something like this in a cycle /between cycles the delay was 10 seconds, a minute, 5 minutes/:

phoneSock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
phoneSock.connect((tgtPhone, port))
phoneSock.send(msg)
while result.find('\n') < 0:
                    result += phoneSock.recv(buff_size)
phoneSock.close()

after some time the connection is not closed and the next cycle goes with an error when trying to connect (114, 'Operation already in progress')
if you add this code after phoneSock.close()
cmd = 'hcitool dc ' + tgtPhone
    ro = os.popen3(cmd)

that connection is always closed
Questions
1) Why is it not closed?
2) How to close the connection correctly - did not find it in the API

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question