1

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.

zky cloudz
  • 23
  • 3
  • Could be there are differences between two versions. Did you check their documentations ? Probably they could contain some insight. Anyway IMO this question is good enough for SO from a new contributor. Hope someone familiar would help you. – Kavindu Dodanduwa Sep 25 '18 at 16:53
  • Yes, I did read the documentation but, the response I received from client socket is rolling over and over again look alike waiting the data. I already spent 2 days on.. – zky cloudz Sep 26 '18 at 03:08

1 Answers1

0

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

  • Hi @DatenDenker, thank you for your reply. Your solution logically could solve the problem. But I already done with the project and stay using python2.7.15. I am really sorry for late reply. I am really apreciate your answer thank you so much :) – zky cloudz Sep 09 '19 at 07:57