Why doesn't it work to enable the client connection in pybluez?

Good time of day.I have a question:why my code gives an error on the connection(I have something wrong).Here is the code
import bluetooth

bd_addr = "01:23:45:67:89:AB"

port = 1

sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM )
sock.connect((bd_addr, port))

sock.send("hello!!")

sock.close()

And here the error:
Traceback (most recent call last):
 File "D:/Рабочий stolperfalle", line 8, in <module>
 sock.connect((bd_addr, port))
 File "D:\2012\lib\site-packages\bluetooth\msbt.py", line 72, in connect
 bt.connect (self._sockfd, addr, port)
OSError</module>

Tell me how correctly to connect,but rather what settings should be to connect?(I have a Bluetooth adpater works)thanks in Advance.
June 27th 19 at 15:11
2 answers
June 27th 19 at 15:13
turn to the sports lottery

I think I already wrote you quote OSError

no court no
June 27th 19 at 15:15
But no.I have now another error is thrown.Here is the code:
from bluetooth import *

server_sock=BluetoothSocket( RFCOMM )
port = 0
server_sock.bind(("",PORT_ANY))
server_sock.listen(1)
server=BluetoothSocket( RFCOMM )
server.connect(('00:11:22:98:76:54',PORT_ANY))

server.send("hello!!")

server.close()

client_sock,address = server_sock.accept()

client_sock.close()
server_sock.close()
server.close()

And here is the error:
Traceback (most recent call last):
 File "D:\Рабочий стол\fhg.py", line 8, in <module>
server.connect(('00:11:22:98:76:54',PORT_ANY))
 File "D:\pythonchik\lib\site-packages\bluetooth\msbt.py", line 72, in connect
 bt.connect (self._sockfd, addr, port)
IOError: the Requested address to your context is incorrect.</module>

I changed the version of Python 2.7.Tell me how to fix this?p.s. if you write what you already wrote,give the solution again.

Find more questions by tags Python