Python3.4.4 Bluetooth pybluez sock.recv

1.5k Views Asked by At

I am working on bluetooth server application using pybluez lib in python. I have 2 version of python installed on my windows 7 PC (python2.7.15 and python 3.4.4) and both already have pybluez modules installed. The program work great in python 2.7.15 but I found a different behaviour in python 3.4.4. In python 2.7.15, function:

socket.recv[1024]

waits until data is available, then step to next line if data is received. But in python 3.4.4, the data is not being waited, thus the program continously execute the next line, even if the data is not received yet. What should I do to make it similar with behaviour in python 2.7.15?

Thanks for your help.

1

There are 1 best solutions below

1
On BEST ANSWER

Just add the line:

while True:
    data = client_sock.recv(1024)
    if len(data) == 0: break
    print("received [%s]" % data)

I have tested is only with python 3.7