john doe
john doe

Reputation: 117

OSError: The requested address is not valid in its context

I am attempting to make a simple bluetooth program in python using pybluez. For the server script I have this code:

import bluetooth as bt

HOST = ""
PORT = 8888

s = bt.BluetoothSocket(bt.RFCOMM)

s.bind((HOST,PORT))
s.listen(1)

conn, addr = s.accept()

print("Connected by", addr)

while True:
    data = conn.recv(1024)
    print(data)

When I attempt to run it I get the Error:

OSError: The requested address is not valid in its context.

I have done extensive research and am unable to find any real cause; it seems to be that pybluez doesn't like to be bound to the address "", but every example I found online said to do that.

Upvotes: 0

Views: 1323

Answers (1)

john doe
john doe

Reputation: 117

I figured out my problem. For RFCOMM connections, the port needs to be even and between 1 and 30. Sorry for any inconvenience.

Upvotes: 2

Related Questions