When creating an AF_BLUETOOTH socket, does one need to connect to the receiving server before sending or can one simply send the data?
When creating an AF_BLUETOOTH socket, does one need to connect to the receiving server before sending or can one simply send the data?
Which is more important in obtaining the truth, "what" or "why"? Trick question. They are of equal importance.
Freely ye have received, freely give.
Although I'm not too familiar with Bluetooth, I'm pretty sure any socket made with socket.socket uses the same abstraction. You need to connect first with socket.connect before using socket.send and socket.recv. I have no idea how you would discover other devices and set up a pairing, though.
Don't use W3Schools as a resource! (Inconsequential foul language at the jump)
Open Linux Forums (More foul language, but well worth it for the quality of support and good humor.)
If you want to discuss W3Schools, please PM me instead of posting.
Sorry, wrong terminology. I meant was a pair required to send data. I'm working on a library and have already accomplish scanning by PIPING out the results of "hcitool scan." It creates a nice list of devices and their device names. This is it so far. I need to know if I can just send the data or if I also must pair the devices. Having only one bluetooth device, I cannot test it.
Code:class tools(): def scan(self): a = subprocess.Popen(["hcitool", "scan"], stdout = subprocess.PIPE).communicate()[0].split()[2:] if a == []: return "ERROR: Device appears to be turned off or not working. Try a device reset \"sudo hciconfig hci0 reset\"" else: return a def send(self, mac, port, string): b = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM) b.connect((mac, port)) b.send(bytes(string, "UTF-8")) b.close()
Which is more important in obtaining the truth, "what" or "why"? Trick question. They are of equal importance.
Freely ye have received, freely give.
Bookmarks