public class ChannelEndPoint extends AbstractEndPoint implements SocketBased
Holds the channel and socket for an NIO endpoint.
Constructor and Description |
---|
ChannelEndPoint(Scheduler scheduler,
SocketChannel channel) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close any backing stream associated with the endpoint
|
int |
fill(ByteBuffer buffer)
Fill the passed buffer with data from this endpoint.
|
boolean |
flush(ByteBuffer... buffers)
Flush data from the passed header/buffer to this endpoint.
|
ByteChannel |
getChannel() |
Socket |
getSocket() |
Object |
getTransport() |
boolean |
isInputShutdown()
Test if the input is shutdown.
|
boolean |
isOpen() |
boolean |
isOutputShutdown()
Test if output is shutdown.
|
protected boolean |
needsFill() |
protected void |
onIncompleteFlush() |
protected void |
shutdownInput() |
void |
shutdownOutput()
Shutdown the output.
|
checkIdleTimeout, fillInterested, getConnection, getCreatedTimeStamp, getFillInterest, getIdleTimeout, getIdleTimestamp, getLocalAddress, getRemoteAddress, getWriteFlusher, notIdle, onClose, onOpen, scheduleIdleTimeout, setConnection, setIdleTimeout, toString, write
public ChannelEndPoint(Scheduler scheduler, SocketChannel channel)
protected void shutdownInput()
public void shutdownOutput()
EndPoint
This call indicates that no more data will be sent on this endpoint that that the remote end should read an EOF once all previously sent data has been consumed. Shutdown may be done either at the TCP/IP level, as a protocol exchange (Eg TLS close handshake) or both.
If the endpoint has EndPoint.isInputShutdown()
true, then this call has the same effect
as EndPoint.close()
.
shutdownOutput
in interface EndPoint
public boolean isOutputShutdown()
EndPoint
EndPoint.shutdownOutput()
or EndPoint.close()
.isOutputShutdown
in interface EndPoint
public boolean isInputShutdown()
EndPoint
EndPoint.fill(ByteBuffer)
. Once the input is shutdown, all calls to
EndPoint.fill(ByteBuffer)
will return -1, until such time as the
end point is close, when they will return EofException
.isInputShutdown
in interface EndPoint
public void close()
EndPoint
public int fill(ByteBuffer buffer) throws IOException
EndPoint
fill
in interface EndPoint
buffer
- The buffer to fill. The position and limit are modified during the fill. After the
operation, the position is unchanged and the limit is increased to reflect the new data filled.int
value indicating the number of bytes
filled or -1 if EOF is read or the input is shutdown.EofException
- If the endpoint is closed.IOException
public boolean flush(ByteBuffer... buffers) throws IOException
EndPoint
flush
in interface EndPoint
EofException
- If the endpoint is closed or output is shutdown.IOException
public ByteChannel getChannel()
public Object getTransport()
getTransport
in interface EndPoint
public Socket getSocket()
getSocket
in interface SocketBased
protected void onIncompleteFlush()
onIncompleteFlush
in class AbstractEndPoint
protected boolean needsFill() throws IOException
needsFill
in class AbstractEndPoint
IOException
Copyright © 1995-2012 Mort Bay Consulting. All Rights Reserved.