Home > Language Reference > Classes > StreamBluetooth
RfCommListen Method
Sets up a socket as a listener using the RfComm protocol.
Syntax
Public Sub RfCommListen(ByRef sUUID As String, ByRef sName As String)
| Parameter | Description |
| sUUID | Identifier of the service to advertise. |
| sName | Name of the service to advertise. |
Remarks
The RfCommListen method sets up a socket as a listener using the RfComm protocol. After the operation completes, the Bluetooth socket behaves as a server, on which remote devices can establish inbound connections. A listening socket cannot exchange data, and thus does not support the Read and Write methods.
The sUUID parameter is the identifier of the service your application provide. This string must conform to one of the following formats, where x is any valid hexadecimal digit:
| Format | Description |
| {xxxx} | One of the 16 bits UUID predefined by the Bluetooth consortium for standard services. |
| {xxxxxxxx} | One of the 32 bits UUID predefined by the Bluetooth consortium for standard services. |
| {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} | Any 128 bits UUID. |
Most of the time, none of the short predefined identifiers will be relevant for the service your application provides, and you'll have to generate your own identifier. Such an identifier can be generated within the HB++ IDE, using the Bluetooth UUID Generator.
The sName parameter is the friendly name of the service your application provides. This string is displayed by some remote applications. You will typically use your application name here.
The following example illustrates how to set up a simple Bluetooth server:
Private sServer As StreamBluetooth
Private Sub Button1_Click()
Set sServer=New StreamBluetooth
Set sServer.Recipient=Me
sServer.RfCommListen "{B34DB148-C94E-11D9-862B-000A9A0054F4}", "MyApplication"
End SubAs soon as the RfCommListen method returns, your application is able to process inbound connections through the ConnectRequest and ConnectedInbound events. The BtChat sample illustrates a simple client/server application based on the RfComm protocol.
System requirements
| System | Minimal version | Remarks |
| Palm OS | Palm OS 5.0 | Requires a Bluetooth enabled device. |