org.apache.tomcat.util.net

Class NioChannel

public class NioChannel extends Object implements 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.ApplicationBufferHandlerbufHandler
protected static ByteBufferemptyBuf
protected NioEndpoint.Pollerpoller
protected SocketChannelsc
protected booleansendFile
Constructor Summary
NioChannel(SocketChannel channel, SecureNioChannel.ApplicationBufferHandler bufHandler)
Method Summary
voidclose()
Closes this channel.
voidclose(boolean force)
booleanflush(boolean block, Selector s, long timeout, MutableInteger lastWrite)
returns true if the network buffer has been flushed out and is empty
booleanflushOutbound()
Return true if the buffer wrote data
ObjectgetAttachment(boolean remove)
intgetBufferSize()
SecureNioChannel.ApplicationBufferHandlergetBufHandler()
getBufHandler
SocketChannelgetIOChannel()
getIOChannel
intgetOutboundRemaining()
NioEndpoint.PollergetPoller()
inthandshake(boolean read, boolean write)
booleanisClosing()
isClosing
booleanisInitHandshakeComplete()
isInitHandshakeComplete
booleanisOpen()
Tells whether or not this channel is open.
booleanisSendFile()
intread(ByteBuffer dst)
Reads a sequence of bytes from this channel into the given buffer.
voidreset()
voidsetIOChannel(SocketChannel IOChannel)
voidsetPoller(NioEndpoint.Poller poller)
voidsetSendFile(boolean s)
StringtoString()
intwrite(ByteBuffer src)
Writes a sequence of bytes to this channel from the given buffer.

Field Detail

bufHandler

protected SecureNioChannel.ApplicationBufferHandler bufHandler

emptyBuf

protected static ByteBuffer emptyBuf

poller

protected NioEndpoint.Poller poller

sc

protected SocketChannel sc

sendFile

protected boolean sendFile

Constructor Detail

NioChannel

public NioChannel(SocketChannel channel, SecureNioChannel.ApplicationBufferHandler bufHandler)

Method Detail

close

public void close()
Closes this channel.

Throws: IOException If an I/O error occurs

UNKNOWN: Implement this java.nio.channels.Channel method

close

public void close(boolean force)

flush

public boolean flush(boolean block, Selector s, long timeout, MutableInteger lastWrite)
returns true if the network buffer has been flushed out and is empty

Returns: boolean

flushOutbound

public boolean flushOutbound()
Return true if the buffer wrote data

Returns:

Throws: IOException

getAttachment

public Object getAttachment(boolean remove)

getBufferSize

public int getBufferSize()

getBufHandler

public SecureNioChannel.ApplicationBufferHandler getBufHandler()
getBufHandler

Returns: ApplicationBufferHandler

UNKNOWN: Implement this org.apache.tomcat.util.net.SecureNioChannel method

getIOChannel

public SocketChannel getIOChannel()
getIOChannel

Returns: SocketChannel

UNKNOWN: Implement this org.apache.tomcat.util.net.SecureNioChannel method

getOutboundRemaining

public int getOutboundRemaining()

getPoller

public NioEndpoint.Poller getPoller()

handshake

public int handshake(boolean read, boolean write)

isClosing

public boolean isClosing()
isClosing

Returns: boolean

UNKNOWN: Implement this org.apache.tomcat.util.net.SecureNioChannel method

isInitHandshakeComplete

public boolean isInitHandshakeComplete()
isInitHandshakeComplete

Returns: boolean

UNKNOWN: Implement this org.apache.tomcat.util.net.SecureNioChannel method

isOpen

public boolean isOpen()
Tells whether or not this channel is open.

Returns: true if, and only if, this channel is open

UNKNOWN: Implement this java.nio.channels.Channel method

isSendFile

public boolean isSendFile()

read

public int read(ByteBuffer dst)
Reads a sequence of bytes from this channel into the given buffer.

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: IOException If some other I/O error occurs

UNKNOWN: Implement this java.nio.channels.ReadableByteChannel method

reset

public void reset()

setIOChannel

public void setIOChannel(SocketChannel IOChannel)

setPoller

public void setPoller(NioEndpoint.Poller poller)

setSendFile

public void setSendFile(boolean s)

toString

public String toString()

write

public int write(ByteBuffer src)
Writes a sequence of bytes to this channel from the given buffer.

Parameters: src The buffer from which bytes are to be retrieved

Returns: The number of bytes written, possibly zero

Throws: IOException If some other I/O error occurs

UNKNOWN: Implement this java.nio.channels.WritableByteChannel method

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