Package org.epics.ca.impl
Class TCPTransport
- java.lang.Object
-
- org.epics.ca.impl.TCPTransport
-
- All Implemented Interfaces:
java.lang.Runnable,ReactorHandler,Transport
public class TCPTransport extends java.lang.Object implements Transport, ReactorHandler, java.lang.Runnable
CA transport implementation.
-
-
Constructor Summary
Constructors Constructor Description TCPTransport(ContextImpl context, TransportClient client, ResponseHandlers.ResponseHandler responseHandler, java.nio.channels.SocketChannel channel, short remoteTransportRevision, int priority)Constructs a new object for managing the TCP connection with a remote server.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanacquire(TransportClient client)Acquires transport.java.nio.ByteBufferacquireSendBuffer(int requiredSize)voidclose(boolean remotelyClosed)Close connection.protected voiddisableFlowControl()Disable flow control (enables events).protected voidenableFlowControl()Enable flow control (disables events).voidflush()protected voidflush(boolean wait)ContextImplgetContext()Get context transport is living in.shortgetMinorRevision()Transport protocol minor revision.intgetPriority()java.net.InetSocketAddressgetRemoteAddress()Get remote address.voidhandleEvent(java.nio.channels.SelectionKey key)Handle IO event.protected voidprocessRead()Process input obtained via channel (read) IO event.protected voidprocessReadBuffer()Process input from receive bufferprotected voidprocessWrite()Process output (write) IO event.voidrelease(TransportClient client)Releases transport.voidreleaseSendBuffer(boolean ignore, boolean flush)voidrun()Echo timer.
-
-
-
Constructor Detail
-
TCPTransport
public TCPTransport(ContextImpl context, TransportClient client, ResponseHandlers.ResponseHandler responseHandler, java.nio.channels.SocketChannel channel, short remoteTransportRevision, int priority)
Constructs a new object for managing the TCP connection with a remote server.- Parameters:
context- the CA context in which the communication takes place.responseHandler- reference to an object which will manage the handling of the server responses.client- the client.channel- socket through which communication will flow.remoteTransportRevision- the CA transport revision (a constant) to be used in communication.priority- the CA message priority.
-
-
Method Detail
-
close
public void close(boolean remotelyClosed)
Close connection.- Parameters:
remotelyClosed- flag indicating weather the socket has already been remotely closed
-
acquire
public boolean acquire(TransportClient client)
Acquires transport.- Parameters:
client- client (channel) acquiring the transport- Returns:
trueif transport was granted,falseotherwise.
-
release
public void release(TransportClient client)
Releases transport.- Parameters:
client- client (channel) releasing the transport
-
getMinorRevision
public short getMinorRevision()
Description copied from interface:TransportTransport protocol minor revision.- Specified by:
getMinorRevisionin interfaceTransport- Returns:
- protocol minor revision.
-
handleEvent
public void handleEvent(java.nio.channels.SelectionKey key)
Handle IO event.- Specified by:
handleEventin interfaceReactorHandler- Parameters:
key- key to be processed.
-
processRead
protected void processRead()
Process input obtained via channel (read) IO event. Also handles subscription flow control.
-
processReadBuffer
protected void processReadBuffer()
Process input from receive buffer
-
processWrite
protected void processWrite()
Process output (write) IO event.
-
disableFlowControl
protected void disableFlowControl()
Disable flow control (enables events).
-
enableFlowControl
protected void enableFlowControl()
Enable flow control (disables events).
-
getContext
public ContextImpl getContext()
Description copied from interface:TransportGet context transport is living in.- Specified by:
getContextin interfaceTransport- Returns:
- context transport is living in.
-
acquireSendBuffer
public java.nio.ByteBuffer acquireSendBuffer(int requiredSize)
- Specified by:
acquireSendBufferin interfaceTransport
-
releaseSendBuffer
public void releaseSendBuffer(boolean ignore, boolean flush)- Specified by:
releaseSendBufferin interfaceTransport
-
flush
protected void flush(boolean wait)
-
getRemoteAddress
public java.net.InetSocketAddress getRemoteAddress()
Description copied from interface:TransportGet remote address.- Specified by:
getRemoteAddressin interfaceTransport- Returns:
- remote address.
-
getPriority
public int getPriority()
- Specified by:
getPriorityin interfaceTransport
-
run
public void run()
Echo timer.- Specified by:
runin interfacejava.lang.Runnable
-
-