Reputation: 1
I'm doing bluetooth socket programming, and I have few questions about sockets provided by BlueZ.
When we're dealing with TCP/IP socket programming, we can usually choose either TCP or UDP as our transport protocol. As far as I know, these two protocols are mutual exclusive (we can only choose one of them).
However, I found that BlueZ provided both L2CAP and RFCOMM sockets for us. For example, in pybluez
, we can choose either bluetooth.L2CAP
or bluetooth.RFCOMM
as an argument to construct a socket.
import bluetooth
server_sock = bluetooth.BluetoothSocket( bluetooth.RFCOMM ) # or bluetooth.L2CAP
My question is: Aren't L2CAP
and RFCOMM
perform different functions and at different levels in the bluetooth stack? In other words, I guess both of them are indispensable, then how could we possibly only choose one of them as a protocol to construct a socket?
Did I misunderstand something? Or it's just that the socket specified in the code just determines the entry position of the socket in the bluetooth stack, with both L2CAP and RFCOMM still functioning? If that is the case, why is BlueZ providing two different socket entries for us?
I have read through the introduction here: https://people.csail.mit.edu/albert/bluez-intro/x95.html, and I know that with L2CAP or RFCOMM specified, we can have different settings, like the number of ports. But I still cannot get which protocols to use and why they exist.
I'm new to Bluetooth, and I will appreciate any of your help very much! Thank you!
Upvotes: 0
Views: 1299