Package org.xnio.channels

# Interface ReadableMessageChannel

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

All Known Subinterfaces:
  `ConnectedMessageChannel`, `MessageChannel`

All Known Implementing Classes:
  `AssembledConnectedMessageChannel`, `AssembledMessageChannel`, `ConduitReadableMessageChannel`, `FramedMessageChannel`

public interface ReadableMessageChannel extends SuspendableReadChannel, Configurable
A channel that can receive messages. Such a channel receives whole messages only.

## Field Summary

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

`EMPTY`

## Method Summary

Modifier and Type
Method
Description
`ChannelListener.Setter<? extends ReadableMessageChannel>`
`getCloseSetter()`
Get the setter which can be used to change the close listener for this channel.
`ChannelListener.Setter<? extends ReadableMessageChannel>`
`getReadSetter()`
Get the setter which can be used to change the read listener for this channel.
`int`
`receive(ByteBuffer buffer)`
Receive a message.
`long`
`receive(ByteBuffer[] buffers)`
Receive a message.
`long`
`receive(ByteBuffer[] buffers, int offs, int len)`
Receive a message.

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

`isOpen`

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

`close, getIoThread, getWorker`

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

`getOption, setOption, supportsOption`

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

`awaitReadable, awaitReadable, getReadThread, isReadResumed, resumeReads, shutdownReads, suspendReads, wakeupReads`

## Method Details

### receive

int receive(ByteBuffer buffer) throws IOException
Receive a message.

Parameters:
  `buffer` - the buffer that will hold the message
Returns:
  the size of the received message, 0 if no message is available, and -1 if the message channel has reached an end-of-file condition
Throws:
  `IOException` - if an I/O error occurs

### receive

long receive(ByteBuffer[] buffers) throws IOException
Receive a message.

Parameters:
  `buffers` - the buffers that will hold the message
Returns:
  the size of the received message, 0 if no message is available, and -1 if the message channel has reached an end-of-file condition
Throws:
  `IOException` - if an I/O error occurs

### receive

long receive(ByteBuffer[] buffers, int offs, int len) throws IOException
Receive a message.

Parameters:
  `buffers` - the buffers that will hold the message
  `offs` - the offset into the array of buffers of the first buffer to read into
  `len` - the number of buffers to fill
Returns:
  the size of the received message, 0 if no message is available, and -1 if the message channel has reached an end-of-file condition
Throws:
  `IOException` - if an I/O error occurs

### getReadSetter

ChannelListener.Setter<? extends ReadableMessageChannel> getReadSetter()
Get the setter which can be used to change the read listener for this channel.

Specified by:
  `getReadSetter` in interface `SuspendableReadChannel`
Returns:
  the setter

### getCloseSetter

ChannelListener.Setter<? extends ReadableMessageChannel> 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.

Specified by:
  `getCloseSetter` in interface `CloseableChannel`
Specified by:
  `getCloseSetter` in interface `SuspendableReadChannel`
Returns:
  the setter