Android.Bluetooth.BluetoothServerSocket Class
A listening Bluetooth socket.

See Also: BluetoothServerSocket Members

Syntax

[Android.Runtime.Register("android/bluetooth/BluetoothServerSocket", DoNotGenerateAcw=true)]
public sealed class BluetoothServerSocket : Java.Lang.Object, Java.IO.ICloseable, IDisposable

Remarks

A listening Bluetooth socket.

The interface for Bluetooth Sockets is similar to that of TCP sockets: Java.Net.Socket and Java.Net.ServerSocket. On the server side, use a Android.Bluetooth.BluetoothServerSocket to create a listening server socket. When a connection is accepted by the Android.Bluetooth.BluetoothServerSocket, it will return a new Android.Bluetooth.BluetoothSocket to manage the connection. On the client side, use a single Android.Bluetooth.BluetoothSocket to both initiate an outgoing connection and to manage the connection.

The most common type of Bluetooth socket is RFCOMM, which is the type supported by the Android APIs. RFCOMM is a connection-oriented, streaming transport over Bluetooth. It is also known as the Serial Port Profile (SPP).

To create a listening Android.Bluetooth.BluetoothServerSocket that's ready for incoming connections, use BluetoothAdapter.ListenUsingRfcommWithServiceRecord(string, Java.Util.UUID). Then call BluetoothServerSocket.Accept to listen for incoming connection requests. This call will block until a connection is established, at which point, it will return a Android.Bluetooth.BluetoothSocket to manage the connection. Once the Android.Bluetooth.BluetoothSocket is acquired, it's a good idea to call BluetoothServerSocket.Close on the Android.Bluetooth.BluetoothServerSocket when it's no longer needed for accepting connections. Closing the Android.Bluetooth.BluetoothServerSocket will not close the returned Android.Bluetooth.BluetoothSocket.

Android.Bluetooth.BluetoothServerSocket is thread safe. In particular, BluetoothServerSocket.Close will always immediately abort ongoing operations and close the server socket.

Note: Requires the NoType:android/Manifest$permission;Href=../../../reference/android/Manifest.permission.html#BLUETOOTH permission.

Developer Guides

For more information about using Bluetooth, read the Bluetooth developer guide.

See Also

[Android Documentation]

Requirements

Namespace: Android.Bluetooth
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 5