BtcServerSocket class Models

A server socket that listens for incoming Bluetooth RFCOMM connections.

Creates an RFCOMM server on the specified UUID and waits for remote devices to connect. Each incoming connection is delivered as a BtcConnection through the connections stream.

Usage

final server = await bluetooth.startServer(
  uuid: '00001101-0000-1000-8000-00805F9B34FB',
  name: 'MyService',
);
server.connections.listen((connection) {
  print('Client connected: ${connection.address}');
  connection.input.listen((data) => print('Data: $data'));
});
// ...later
await server.close();

Platform Support

Platform Supported
Android Yes
Windows Yes
macOS Yes
Linux Yes
iOS No (no server mode)

Constructors

BtcServerSocket({required int id, required String uuid, required String serviceName, required MethodChannel methodChannel})
Creates a BtcServerSocket wrapping the native server id.

Properties

connections Stream<BtcConnection>
Stream of incoming connections from remote devices.
no setter
hashCode int
The hash code for this object.
no setterinherited
id int
Unique identifier for this server assigned by the native side.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
serviceName String
The human-readable service name.
final
uuid String
The UUID used for the RFCOMM service record.
final

Methods

close() Future<void>
Stops the server and releases the RFCOMM channel.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited