Overview | Package | Class | Tree | Deprecated | Index | Help
| Apache Tomcat 6.0.43
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.tomcat.util.net
Class NioChannel

    java.lang.Object
      org.apache.tomcat.util.net.NioChannel

All Implemented Interfaces:
  java.io.Closeable, java.nio.channels.ByteChannel, java.nio.channels.Channel, java.nio.channels.ReadableByteChannel, java.nio.channels.WritableByteChannel

Direct Known Subclasses:
  SecureNioChannel

    public class NioChannel

extends java.lang.Object
implements java.nio.channels.ByteChannel

Base class for a SocketChannel wrapper used by the endpoint. This way, logic for a SSL socket channel remains the same as for a non SSL, making sure we don't need to code for any exception cases.

Version:
  1.0
Author:
  Filip Hanik

Field Summary
`protected SecureNioChannel.ApplicationBufferHandler` | `bufHandler`
`protected static java.nio.ByteBuffer` | `emptyBuf`
`protected NioEndpoint.Poller` | `poller`
`protected java.nio.channels.SocketChannel` | `sc`
`protected boolean` | `sendFile`

Constructor Summary
`NioChannel(java.nio.channels.SocketChannel channel, SecureNioChannel.ApplicationBufferHandler bufHandler)`

Method Summary
`void` | `close()` Closes this channel.
`void` | `close(boolean force)`
`boolean` | `flush(boolean block, java.nio.channels.Selector s, long timeout, MutableInteger lastWrite)` returns true if the network buffer has been flushed out and is empty
`boolean` | `flushOutbound()` Return true if the buffer wrote data.
`java.lang.Object` | `getAttachment(boolean remove)`
`int` | `getBufferSize()`
`SecureNioChannel.ApplicationBufferHandler` | `getBufHandler()`
`java.nio.channels.SocketChannel` | `getIOChannel()`
`int` | `getOutboundRemaining()`
`NioEndpoint.Poller` | `getPoller()`
`int` | `handshake(boolean read, boolean write)`
`boolean` | `isClosing()`
`boolean` | `isInitHandshakeComplete()`
`boolean` | `isOpen()` Tells whether or not this channel is open.
`boolean` | `isSendFile()`
`int` | `read(java.nio.ByteBuffer dst)` Reads a sequence of bytes from this channel into the given buffer.
`void` | `reset()`
`void` | `setIOChannel(java.nio.channels.SocketChannel IOChannel)`
`void` | `setPoller(NioEndpoint.Poller poller)`
`void` | `setSendFile(boolean s)`
`java.lang.String` | `toString()`
`int` | `write(java.nio.ByteBuffer src)` Writes a sequence of bytes to this channel from the given buffer.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### emptyBuf

    protected static java.nio.ByteBuffer emptyBuf

### sc

    protected java.nio.channels.SocketChannel sc

### bufHandler

    protected SecureNioChannel.ApplicationBufferHandler bufHandler

### poller

    protected NioEndpoint.Poller poller

### sendFile

    protected boolean sendFile

Constructor Detail

### NioChannel

    public NioChannel(java.nio.channels.SocketChannel channel,
                      SecureNioChannel.ApplicationBufferHandler bufHandler)
               throws java.io.IOException

Throws:
  `java.io.IOException`

Method Detail

### reset

    public void reset()
               throws java.io.IOException

  Throws:
    `java.io.IOException`

### getBufferSize

    public int getBufferSize()

### flush

    public boolean flush(boolean block,
                         java.nio.channels.Selector s,
                         long timeout,
                         MutableInteger lastWrite)
                  throws java.io.IOException

  returns true if the network buffer has been flushed out and is empty

  Returns:
    boolean
  Throws:
    `java.io.IOException`

### close

    public void close()
               throws java.io.IOException

  Closes this channel.

  Specified by:
    `close` in interface `java.io.Closeable`
  Specified by:
    `close` in interface `java.nio.channels.Channel`
  Throws:
    `java.io.IOException` - If an I/O error occurs

### close

    public void close(boolean force)
               throws java.io.IOException

  Throws:
    `java.io.IOException`

### isOpen

    public boolean isOpen()

  Tells whether or not this channel is open.

  Specified by:
    `isOpen` in interface `java.nio.channels.Channel`
  Returns:
    `true` if, and only if, this channel is open

### write

    public int write(java.nio.ByteBuffer src)
              throws java.io.IOException

  Writes a sequence of bytes to this channel from the given buffer.

  Specified by:
    `write` in interface `java.nio.channels.WritableByteChannel`
  Parameters:
    `src` - The buffer from which bytes are to be retrieved
  Returns:
    The number of bytes written, possibly zero
  Throws:
    `java.io.IOException` - If some other I/O error occurs

### read

    public int read(java.nio.ByteBuffer dst)
             throws java.io.IOException

  Reads a sequence of bytes from this channel into the given buffer.

  Specified by:
    `read` in interface `java.nio.channels.ReadableByteChannel`
  Parameters:
    `dst` - The buffer into which bytes are to be transferred
  Returns:
    The number of bytes read, possibly zero, or `-1` if the channel has reached end-of-stream
  Throws:
    `java.io.IOException` - If some other I/O error occurs

### getAttachment

    public java.lang.Object getAttachment(boolean remove)

### getBufHandler

    public SecureNioChannel.ApplicationBufferHandler getBufHandler()

### getPoller

    public NioEndpoint.Poller getPoller()

### getIOChannel

    public java.nio.channels.SocketChannel getIOChannel()

### isClosing

    public boolean isClosing()

### isInitHandshakeComplete

    public boolean isInitHandshakeComplete()

### handshake

    public int handshake(boolean read,
                         boolean write)
                  throws java.io.IOException

  Throws:
    `java.io.IOException`

### setPoller

    public void setPoller(NioEndpoint.Poller poller)

### setIOChannel

    public void setIOChannel(java.nio.channels.SocketChannel IOChannel)

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### getOutboundRemaining

    public int getOutboundRemaining()

### flushOutbound

    public boolean flushOutbound()
                          throws java.io.IOException

  Return true if the buffer wrote data.

  Throws:
    `java.io.IOException`

### isSendFile

    public boolean isSendFile()

### setSendFile

    public void setSendFile(boolean s)

Overview | Package | Class | Tree | Deprecated | Index | Help
| Apache Tomcat 6.0.43
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.