Platforms to show: All Mac Windows Linux Cross-Platform

Back to WindowsBlueToothSocketMBS class.

WindowsBlueToothSocketMBS.Accept(byref RemoteAddress as String, byref RemotePort as Integer, NewSocket as WindowsBlueToothSocketMBS) as WindowsBlueToothSocketMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Bluetooth MBS Bluetooth Plugin 18.1 ❌ No ✅ Yes ❌ No ❌ No All
Accepts a new incoming connection.

Bluetooth uses the accept function to enable incoming connection attempts on a socket.
RemoteAddress and RemotePort are set to address of remote peer.

If you like to pass in your own subclass object for NewSocket, we can use that socket object. Otherwise, we make a new WindowsBlueToothSocketMBS object.

Lasterror is set.

WindowsBlueToothSocketMBS.Bind(Port as Integer = -1, BluetoothAddress as string = "")

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Bluetooth MBS Bluetooth Plugin 18.1 ❌ No ✅ Yes ❌ No ❌ No All
Binds to a port and optional address.

Lasterror is set.
BindAddress and BindPort are set.
BluetoothAddress: When used with the bind function, must be "" or a valid local radio address.
Port: Must be -1 for automatic or valid port from 1 to 30.

On client applications, the port member must be zero to enable an appropriate local endpoint to be assigned. On server applications, the port member must be a valid port number or kPortAny; ports automatically assigned using kPortAny may be queried subsequently with a call to the getsockname function. The valid range for requesting a specific RFCOMM port is 1 through 30. Server channels are global resource, and only 30 server channels are available for RFCOMM on any Bluetooth device, which must be shared by all Windows Sockets that belong to the Bluetooth address family. If no server channel is available, or if the specified server channel is already reserved, the bind call fails.

Upon successful return from bind, the server channel is reserved until the socket is closed. Use the getsockname function to retrieve the channel number for SDP registration.

Applications should use auto-allocation for the server channel.
The bind function does not automatically advertise the server application using the Bluetooth SDP; applications must call the Publish function.

WindowsBlueToothSocketMBS.Close

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Bluetooth MBS Bluetooth Plugin 18.3 ❌ No ✅ Yes ❌ No ❌ No All
Closes socket.

Called by destructor.
Does also UnpublishRecord if needed.

WindowsBlueToothSocketMBS.Connect(BluetoothAddress as string, Port as Integer, ServiceClassGUID as String = "", Blocking as boolean = true)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Bluetooth MBS Bluetooth Plugin 18.1 ❌ No ✅ Yes ❌ No ❌ No All
Connects to a bluetooth device.

Valid ports in range 1 to 31.
Lasterror is set.

BluetoothAddress: Address of the target Bluetooth device. If zero, a valid local Bluetooth device address is assigned when the connect or accept function is called. When used with the connect function, a valid remote radio address must be specified.
serviceClassId

Service Class Identifier of the socket. When used with the bind function, serviceClassId is ignored. Also ignored if the port is specified. For the connect function, specifies the unique Bluetooth service class ID of the service to which it wants to connect. If the peer device has more than one port that corresponds to the service class identifier, the connect function attempts to connect to the first valid service; this mechanism can be used without prior SDP queries.
port: RFCOMM channel associated with the socket.

Added Blocking parameter in v23.4. If true, we block, so connect returns after connection is done. Pass false to return directly and check status later.

WindowsBlueToothSocketMBS.Constructor

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Bluetooth MBS Bluetooth Plugin 18.1 ❌ No ✅ Yes ❌ No ❌ No All
Creates a new socket.

Socket address type is always AF_BTH, type is SOCK_STREAM and protocol is BTHPROTO_RFCOMM.

WindowsBlueToothSocketMBS.Listen(BackLog as Integer = 2)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Bluetooth MBS Bluetooth Plugin 18.1 ❌ No ✅ Yes ❌ No ❌ No All
Listens for connections on this socket.

Lasterror is set.

WindowsBlueToothSocketMBS.Poll

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Bluetooth MBS Bluetooth Plugin 18.1 ❌ No ✅ Yes ❌ No ❌ No All
Polls for new events.

May call NewConnection or DataAvailable event if data is available.
Calls SendComplete when sending is done.
Calls Error event when an error occurred.

This is normally called automatically by a timer for you.
But if you are in a tight loop, you can call it manually.

WindowsBlueToothSocketMBS.PublishRecord(SDPRecord as MemoryBlock)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Bluetooth MBS Bluetooth Plugin 18.1 ❌ No ✅ Yes ❌ No ❌ No All
Publish service record.

Lasterror is set.
Sets the SDPRecordID property.

WindowsBlueToothSocketMBS.Read(size as integer, peek as boolean = false) as String

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Bluetooth MBS Bluetooth Plugin 18.1 ❌ No ✅ Yes ❌ No ❌ No All
Reads data.

Please pass in size of desired data length to read.
Lasterror is set.
New data is returned (maybe shorter).
If peek is true, data is not removed from buffers.

WindowsBlueToothSocketMBS.ReadAll(peek as boolean = false) as String

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Bluetooth MBS Bluetooth Plugin 18.1 ❌ No ✅ Yes ❌ No ❌ No All
Reads all available data.

Lasterror is set.
New data is returned.
If peek is true, data is not removed from buffers.

WindowsBlueToothSocketMBS.RegisterService(ServiceClassGUID as String, InstanceName as String, Comment as String = "")

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Bluetooth MBS Bluetooth Plugin 18.1 ❌ No ✅ Yes ❌ No ❌ No All
Registers service.

Lasterror is set.

WindowsBlueToothSocketMBS.Send(data as MemoryBlock) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Bluetooth MBS Bluetooth Plugin 18.1 ❌ No ✅ Yes ❌ No ❌ No All
Sends data.

Lasterror is set.
Returns number of bytes sent.
Later raises SendComplete event when sending is done.

See also:

WindowsBlueToothSocketMBS.Send(data as String) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Bluetooth MBS Bluetooth Plugin 18.1 ❌ No ✅ Yes ❌ No ❌ No All
Sends data.

Lasterror is set.
Returns number of bytes sent.
Later raises SendComplete event when sending is done.

See also:

WindowsBlueToothSocketMBS.UnpublishRecord

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Bluetooth MBS Bluetooth Plugin 18.1 ❌ No ✅ Yes ❌ No ❌ No All
Unpublish service record.

Lasterror is set.
Clears SDPRecordID property.

The items on this page are in the following plugins: MBS Bluetooth Plugin.


The biggest plugin in space...