org.eclipse.jetty.io.nio
public class ChannelEndPoint extends java.lang.Object implements EndPoint
Holds the channel and socket for an NIO endpoint.
Modifier and Type | Field and Description |
---|---|
protected java.nio.channels.ByteChannel |
_channel |
protected java.nio.ByteBuffer[] |
_gather2 |
protected java.net.InetSocketAddress |
_local |
protected int |
_maxIdleTime |
protected java.net.InetSocketAddress |
_remote |
protected java.net.Socket |
_socket |
Modifier | Constructor and Description |
---|---|
|
ChannelEndPoint(java.nio.channels.ByteChannel channel) |
protected |
ChannelEndPoint(java.nio.channels.ByteChannel channel,
int maxIdleTime) |
Modifier and Type | Method and Description |
---|---|
boolean |
blockReadable(long millisecs) |
boolean |
blockWritable(long millisecs) |
void |
close()
Close any backing stream associated with the endpoint
|
int |
fill(Buffer buffer)
Fill the buffer from the current putIndex to it's capacity from whatever
byte source is backing the buffer.
|
void |
flush()
Flush any buffered output.
|
int |
flush(Buffer buffer)
Flush the buffer from the current getIndex to it's putIndex using whatever byte
sink is backing the buffer.
|
int |
flush(Buffer header,
Buffer buffer,
Buffer trailer)
Flush the buffer from the current getIndex to it's putIndex using whatever byte
sink is backing the buffer.
|
protected int |
gatheringFlush(Buffer header,
java.nio.ByteBuffer bbuf0,
Buffer buffer,
java.nio.ByteBuffer bbuf1) |
java.nio.channels.ByteChannel |
getChannel() |
java.lang.String |
getLocalAddr() |
java.lang.String |
getLocalHost() |
int |
getLocalPort() |
int |
getMaxIdleTime()
Get the max idle time in ms.
|
java.lang.String |
getRemoteAddr() |
java.lang.String |
getRemoteHost() |
int |
getRemotePort() |
java.lang.Object |
getTransport() |
boolean |
isBlocking() |
boolean |
isInputShutdown() |
boolean |
isOpen() |
boolean |
isOutputShutdown() |
void |
setMaxIdleTime(int timeMs)
Set the max idle time.
|
protected void |
shutdownChannelInput()
Shutdown the channel Input.
|
protected void |
shutdownChannelOutput() |
void |
shutdownInput()
Shutdown any backing input stream associated with the endpoint
|
void |
shutdownOutput()
Shutdown any backing output stream associated with the endpoint
|
protected final java.nio.channels.ByteChannel _channel
protected final java.nio.ByteBuffer[] _gather2
protected final java.net.Socket _socket
protected final java.net.InetSocketAddress _local
protected final java.net.InetSocketAddress _remote
protected volatile int _maxIdleTime
public ChannelEndPoint(java.nio.channels.ByteChannel channel) throws java.io.IOException
java.io.IOException
protected ChannelEndPoint(java.nio.channels.ByteChannel channel, int maxIdleTime) throws java.io.IOException
java.io.IOException
public boolean isBlocking()
isBlocking
in interface EndPoint
public boolean blockReadable(long millisecs) throws java.io.IOException
blockReadable
in interface EndPoint
java.io.IOException
public boolean blockWritable(long millisecs) throws java.io.IOException
blockWritable
in interface EndPoint
java.io.IOException
protected final void shutdownChannelInput() throws java.io.IOException
shutdownInput()
java.io.IOException
public void shutdownInput() throws java.io.IOException
EndPoint
shutdownInput
in interface EndPoint
java.io.IOException
protected final void shutdownChannelOutput() throws java.io.IOException
java.io.IOException
public void shutdownOutput() throws java.io.IOException
EndPoint
shutdownOutput
in interface EndPoint
java.io.IOException
public boolean isOutputShutdown()
isOutputShutdown
in interface EndPoint
public boolean isInputShutdown()
isInputShutdown
in interface EndPoint
public void close() throws java.io.IOException
EndPoint
public int fill(Buffer buffer) throws java.io.IOException
EndPoint
fill
in interface EndPoint
int
value indicating the number of bytes
filled or -1 if EOF is reached.EofException
- If input is shutdown or the endpoint is closed.java.io.IOException
public int flush(Buffer buffer) throws java.io.IOException
EndPoint
flush
in interface EndPoint
buffer
- The buffer to flush. This buffers getIndex is updated.EofException
- If the endpoint is closed or output is shutdown.java.io.IOException
public int flush(Buffer header, Buffer buffer, Buffer trailer) throws java.io.IOException
EndPoint
flush
in interface EndPoint
header
- A buffer to write before flushing this buffer. This buffers getIndex is updated.buffer
- The buffer to flush. This buffers getIndex is updated.trailer
- A buffer to write after flushing this buffer. This buffers getIndex is updated.java.io.IOException
protected int gatheringFlush(Buffer header, java.nio.ByteBuffer bbuf0, Buffer buffer, java.nio.ByteBuffer bbuf1) throws java.io.IOException
java.io.IOException
public java.nio.channels.ByteChannel getChannel()
public java.lang.String getLocalAddr()
getLocalAddr
in interface EndPoint
EndPoint
is bound, or null
if this EndPoint
does not represent a network connection.public java.lang.String getLocalHost()
getLocalHost
in interface EndPoint
EndPoint
is bound, or null
if this EndPoint
does not represent a network connection.public int getLocalPort()
getLocalPort
in interface EndPoint
EndPoint
is listening, or 0
if this EndPoint
does not represent a network connection.public java.lang.String getRemoteAddr()
getRemoteAddr
in interface EndPoint
EndPoint
is connected, or null
if this EndPoint
does not represent a network connection.public java.lang.String getRemoteHost()
getRemoteHost
in interface EndPoint
EndPoint
is connected, or null
if this EndPoint
does not represent a network connection.public int getRemotePort()
getRemotePort
in interface EndPoint
EndPoint
is connected, or 0
if this EndPoint
does not represent a network connection.public java.lang.Object getTransport()
getTransport
in interface EndPoint
public void flush() throws java.io.IOException
EndPoint
flush
in interface EndPoint
EofException
- If the endpoint is closed or output is shutdown.java.io.IOException
public int getMaxIdleTime()
EndPoint
The max idle time is the time the endpoint can be idle before
extraordinary handling takes place. This loosely corresponds to
the Socket.getSoTimeout()
for blocking connections,
but AsyncEndPoint
implementations must use other mechanisms
to implement the max idle time.
getMaxIdleTime
in interface EndPoint
public void setMaxIdleTime(int timeMs) throws java.io.IOException
EndPoint
setMaxIdleTime
in interface EndPoint
timeMs
- the max idle time in MS. Timeout <= 0 implies an infinite timeoutjava.io.IOException
- if the timeout cannot be set.StreamEndPoint.setMaxIdleTime(int)
Copyright © 2017. All Rights Reserved.