Package org.xnio.channels

# Interface CloseableChannel

All Superinterfaces:
  `AutoCloseable`, `Channel`, `Closeable`, `Configurable`, `InterruptibleChannel`

All Known Subinterfaces:
  `AcceptingChannel<C>`, `BoundChannel`, `BoundMultipointMessageChannel`, `ConnectedChannel`, `ConnectedMessageChannel`, `ConnectedSslStreamChannel`, `ConnectedStreamChannel`, `MessageChannel`, `MulticastMessageChannel`, `MultipointMessageChannel`, `ReadableMessageChannel`, `ReadableMultipointMessageChannel`, `SimpleAcceptingChannel<C>`, `SslChannel`, `StreamChannel`, `StreamSinkChannel`, `StreamSourceChannel`, `SuspendableAcceptChannel`, `SuspendableChannel`, `SuspendableReadChannel`, `SuspendableWriteChannel`, `WritableMessageChannel`, `WritableMultipointMessageChannel`

All Known Implementing Classes:
  `AssembledChannel`, `AssembledConnectedChannel`, `AssembledConnectedMessageChannel`, `AssembledConnectedSslStreamChannel`, `AssembledConnectedStreamChannel`, `AssembledMessageChannel`, `AssembledSslChannel`, `AssembledStreamChannel`, `ConduitReadableMessageChannel`, `ConduitStreamSinkChannel`, `ConduitStreamSourceChannel`, `ConduitWritableMessageChannel`, `Connection`, `EmptyStreamSourceChannel`, `FixedLengthStreamSinkChannel`, `FixedLengthStreamSourceChannel`, `FramedMessageChannel`, `JsseSslConnection`, `JsseSslStreamConnection`, `MessageConnection`, `NullStreamSinkChannel`, `PushBackStreamChannel`, `SplitStreamSinkChannel`, `SplitStreamSourceChannel`, `SslConnection`, `StreamConnection`, `TranslatingSuspendableChannel`

public interface CloseableChannel extends InterruptibleChannel, Configurable
A channel which is closeable. A listener may be registered which is triggered (only once) on channel close.

Since:
  2.0

## Field Summary

### Fields inherited from interface org.xnio.channels.Configurable

`EMPTY`

## Method Summary

Modifier and Type
Method
Description
`void`
`close()`
Close this channel.
`ChannelListener.Setter<? extends CloseableChannel>`
`getCloseSetter()`
Get the setter which can be used to change the close listener for this channel.
`XnioIoThread`
`getIoThread()`
Get the I/O thread associated with this channel.
`XnioWorker`
`getWorker()`
Get the worker for this channel.

### Methods inherited from interface java.nio.channels.Channel

`isOpen`

### Methods inherited from interface org.xnio.channels.Configurable

`getOption, setOption, supportsOption`

## Method Details

### getCloseSetter

ChannelListener.Setter<? extends CloseableChannel> getCloseSetter()
Get the setter which can be used to change the close listener for this channel. If the channel is already closed, then the listener will not be called.

Returns:
  the setter

### getWorker

XnioWorker getWorker()
Get the worker for this channel.

Returns:
  the worker

### getIoThread

XnioIoThread getIoThread()
Get the I/O thread associated with this channel.

Returns:
  the I/O thread associated with this channel

### close

void close() throws IOException
Close this channel. When a channel is closed, its close listener is invoked. Invoking this method more than once has no additional effect.

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Channel`
Specified by:
  `close` in interface `Closeable`
Specified by:
  `close` in interface `InterruptibleChannel`
Throws:
  `IOException` - if the close failed