# Class RfcommConnection

java.lang.Object
com.codename1.bluetooth.classic.RfcommConnection

public abstract class RfcommConnection extends Object

An open RFCOMM (Serial Port Profile style) stream connection to a classic Bluetooth device, obtained via `BluetoothClassic.connect(BluetoothDevice, BluetoothUuid, boolean)` or accepted from an `RfcommServer`.

The streams block and must be consumed off the EDT; reads/writes throw plain `java.io.IOException` on transport failure. Always `close()` the connection when done.

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `RfcommConnection(BluetoothDevice device)`
  Constructed by ports; not application API.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `abstract void`
  `close()`
  Closes the connection and both streams.
  `BluetoothDevice`
  `getDevice()`
  The remote device of this connection.
  `abstract InputStream`
  `getInputStream()`
  The blocking input stream; consume off the EDT.
  `abstract OutputStream`
  `getOutputStream()`
  The blocking output stream; use off the EDT.
  `abstract boolean`
  `isOpen()`
  `true` while the connection is open.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### RfcommConnection

    protected RfcommConnection(BluetoothDevice device)
    Constructed by ports; not application API.

- ## Method Details

  - ### getInputStream

    public abstract InputStream getInputStream() throws IOException
    The blocking input stream; consume off the EDT.
    Throws:
      `IOException`

  - ### getOutputStream

    public abstract OutputStream getOutputStream() throws IOException
    The blocking output stream; use off the EDT.
    Throws:
      `IOException`

  - ### close

    public abstract void close() throws IOException
    Closes the connection and both streams.
    Throws:
      `IOException`

  - ### isOpen

    public abstract boolean isOpen()
    `true` while the connection is open.

  - ### getDevice

    public BluetoothDevice getDevice()
    The remote device of this connection.