org.apache.mina.transport.nio

## Class NioUdpSession

- java.lang.Object
- - org.apache.mina.session.AbstractIoSession
  - - org.apache.mina.transport.nio.AbstractNioSession
    - - org.apache.mina.transport.nio.NioUdpSession

All Implemented Interfaces:
  IoSession, ReadFilterChainController, WriteFilterChainController, SelectorListener

    public class NioUdpSession
    extends AbstractNioSession
    implements SelectorListener

A UDP session based on NIO

Author:
  Apache MINA Project

### Nested Class Summary

### Nested classes/interfaces inherited from interface org.apache.mina.api.IoSession

`IoSession.SessionState`

### Field Summary

### Fields inherited from class org.apache.mina.transport.nio.AbstractNioSession

`channel`

### Fields inherited from class org.apache.mina.session.AbstractIoSession

`config, idleChecker, secured, state`

### Fields inherited from interface org.apache.mina.api.IoSession

`SSL_HELPER`

### Method Summary

Methods
`protected void` `channelClose()` Close the inner socket channel
`protected ByteBuffer` `convertToDirectBuffer(WriteRequest writeRequest, boolean createNew)` Copy the HeapBuffer into a DirectBuffer, if needed.
`void` `flushWriteQueue()`
`UdpSessionConfig` `getConfig()` Gets the session configuration, it where the idle timeout are set and other transport specific configuration.
`SocketAddress` `getLocalAddress()` Gets the local address of the local peer.
`SocketAddress` `getRemoteAddress()` Returns the socket address of remote peer.
`boolean` `isReadSuspended()` Is read operation is suspended for this session.
`boolean` `isWriteSuspended()` Is write operation is suspended for this session.
`void` `ready(boolean accept, boolean connect, boolean read, ByteBuffer readBuffer, boolean write)`
`void` `resumeRead()` Resumes read operations for this session.
`void` `resumeWrite()` Resumes write operations for this session.
`void` `suspendRead()` Suspends read operations for this session.
`void` `suspendWrite()` Suspends write operations for this session.
`protected int` `writeDirect(Object message)` Writes the message immediately.

### Methods inherited from class org.apache.mina.transport.nio.AbstractNioSession

`close, enqueueWriteRequest, getWriteQueue, isRegisteredForWrite, processWrite, setNotRegisteredForWrite`

### Methods inherited from class org.apache.mina.session.AbstractIoSession

`callReadNextFilter, callWriteNextFilter, changeState, getAttribute, getAttribute, getAttributeKeys, getCreationTime, getId, getLastIoTime, getLastReadTime, getLastWriteTime, getReadBytes, getService, getWrittenBytes, incrementWrittenBytes, initSecure, isClosed, isClosing, isConnected, isConnectedSecured, isCreated, isSecured, isSecuring, processException, processMessageReceived, processMessageSent, processMessageWriting, processSessionClosed, processSessionIdle, processSessionOpen, removeAttribute, setAttribute, setSecured, toString, write, writeWithFuture`

### Methods inherited from class java.lang.Object

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

### Method Detail

#### channelClose

    protected void channelClose()

Close the inner socket channel

Specified by:
  `channelClose` in class `AbstractNioSession`

#### flushWriteQueue

    public void flushWriteQueue()

Specified by:
  `flushWriteQueue` in class `AbstractNioSession`

#### getRemoteAddress

    public SocketAddress getRemoteAddress()

Returns the socket address of remote peer.

Specified by:
  `getRemoteAddress` in interface `IoSession`
Returns:
  the remote socket address

#### getLocalAddress

    public SocketAddress getLocalAddress()

Gets the local address of the local peer.

Specified by:
  `getLocalAddress` in interface `IoSession`
Returns:
  the socket address of local machine which is associated with this session.

#### suspendRead

    public void suspendRead()

Suspends read operations for this session.

Specified by:
  `suspendRead` in interface `IoSession`

#### suspendWrite

    public void suspendWrite()

Suspends write operations for this session.

Specified by:
  `suspendWrite` in interface `IoSession`

#### resumeRead

    public void resumeRead()

Resumes read operations for this session.

Specified by:
  `resumeRead` in interface `IoSession`

#### resumeWrite

    public void resumeWrite()

Resumes write operations for this session.

Specified by:
  `resumeWrite` in interface `IoSession`

#### isReadSuspended

    public boolean isReadSuspended()

Is read operation is suspended for this session.

Specified by:
  `isReadSuspended` in interface `IoSession`
Returns:
  `true` if suspended

#### isWriteSuspended

    public boolean isWriteSuspended()

Is write operation is suspended for this session.

Specified by:
  `isWriteSuspended` in interface `IoSession`
Returns:
  `true` if suspended

#### getConfig

    public UdpSessionConfig getConfig()

Gets the session configuration, it where the idle timeout are set and other transport specific configuration.

Specified by:
  `getConfig` in interface `IoSession`
Returns:
  the session's configuration

#### writeDirect

    protected int writeDirect(Object message)

Writes the message immediately. If we can't write all the message, we will get back the number of written bytes.

Specified by:
  `writeDirect` in class `AbstractNioSession`
Parameters:
  `message` - the message to write
Returns:
  the number of written bytes

#### convertToDirectBuffer

    protected ByteBuffer convertToDirectBuffer(WriteRequest writeRequest,
                                   boolean createNew)

Copy the HeapBuffer into a DirectBuffer, if needed.

Specified by:
  `convertToDirectBuffer` in class `AbstractNioSession`
Parameters:
  `writeRequest` - The request containing the HeapBuffer
  `createNew` - A flag to force the creation of a DirectBuffer
Returns:
  A DirectBuffer

#### ready

    public void ready(boolean accept,
             boolean connect,
             boolean read,
             ByteBuffer readBuffer,
             boolean write)

Specified by:
  `ready` in interface `SelectorListener`