# Class L2capChannel

java.lang.Object
com.codename1.bluetooth.le.L2capChannel

public abstract class L2capChannel extends Object

An open L2CAP connection-oriented channel -- a raw bidirectional byte stream to a peripheral, obtained via `BlePeripheral.openL2capChannel(int, boolean)` on the central side or accepted from an `L2capServer` on the peripheral side.

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

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `L2capChannel(int psm)`
  Constructed by ports; not application API.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `abstract void`
  `close()`
  Closes the channel and both streams.
  `abstract InputStream`
  `getInputStream()`
  The blocking input stream of the channel; consume off the EDT.
  `abstract OutputStream`
  `getOutputStream()`
  The blocking output stream of the channel; use off the EDT.
  `int`
  `getPsm()`
  The Protocol/Service Multiplexer this channel is bound to.
  `abstract boolean`
  `isOpen()`
  `true` while the channel is open.

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### L2capChannel

    protected L2capChannel(int psm)
    Constructed by ports; not application API.

- ## Method Details

  - ### getInputStream

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

  - ### getOutputStream

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

  - ### close

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

  - ### isOpen

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

  - ### getPsm

    public int getPsm()
    The Protocol/Service Multiplexer this channel is bound to.