synergynetframework.appsystem.services.net.objectmessaging.connections
Class TCPConnectionHandler

java.lang.Object
  extended by synergynetframework.appsystem.services.net.objectmessaging.connections.TCPConnectionHandler

public class TCPConnectionHandler
extends java.lang.Object

The Class TCPConnectionHandler.


Constructor Summary
TCPConnectionHandler(ConnectionHandler connectionHandler, int bufferSize)
          Instantiates a new TCP connection handler.
 
Method Summary
 java.nio.channels.SelectionKey accept(java.nio.channels.Selector selector, java.nio.channels.SocketChannel socketChannel)
          Accept.
 void close()
          Close.
 void connect(java.nio.channels.Selector selector, java.net.SocketAddress remoteAddress, int timeout)
          Connect.
 int getAliveTime()
          Gets the alive time.
 java.nio.ByteBuffer getReadBuffer()
          Gets the read buffer.
 java.nio.channels.SocketChannel getSocketChannel()
          Gets the socket channel.
 java.nio.ByteBuffer getWriteBuffer()
          Gets the write buffer.
 boolean needsKeepAlive()
          Needs keep alive.
 java.lang.Object readObject()
          Read object.
 int send(java.lang.Object object)
          Send.
 void setAliveTime(int aliveTime)
          Sets the alive time.
 void writeOperation()
          Write operation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TCPConnectionHandler

public TCPConnectionHandler(ConnectionHandler connectionHandler,
                            int bufferSize)
Instantiates a new TCP connection handler.

Parameters:
connectionHandler - the connection handler
bufferSize - the buffer size
Method Detail

accept

public java.nio.channels.SelectionKey accept(java.nio.channels.Selector selector,
                                             java.nio.channels.SocketChannel socketChannel)
                                      throws java.io.IOException
Accept.

Parameters:
selector - the selector
socketChannel - the socket channel
Returns:
the selection key
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

close

public void close()
Close.


connect

public void connect(java.nio.channels.Selector selector,
                    java.net.SocketAddress remoteAddress,
                    int timeout)
             throws java.io.IOException
Connect.

Parameters:
selector - the selector
remoteAddress - the remote address
timeout - the timeout
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

getAliveTime

public int getAliveTime()
Gets the alive time.

Returns:
the alive time

getReadBuffer

public java.nio.ByteBuffer getReadBuffer()
Gets the read buffer.

Returns:
the read buffer

getSocketChannel

public java.nio.channels.SocketChannel getSocketChannel()
Gets the socket channel.

Returns:
the socket channel

getWriteBuffer

public java.nio.ByteBuffer getWriteBuffer()
Gets the write buffer.

Returns:
the write buffer

needsKeepAlive

public boolean needsKeepAlive()
Needs keep alive.

Returns:
true, if successful

readObject

public java.lang.Object readObject()
                            throws java.io.IOException,
                                   SerializationException
Read object.

Returns:
the object
Throws:
java.io.IOException - Signals that an I/O exception has occurred.
SerializationException - the serialization exception

send

public int send(java.lang.Object object)
         throws java.io.IOException,
                SerializationException
Send.

Parameters:
object - the object
Returns:
the int
Throws:
java.io.IOException - Signals that an I/O exception has occurred.
SerializationException - the serialization exception

setAliveTime

public void setAliveTime(int aliveTime)
Sets the alive time.

Parameters:
aliveTime - the new alive time

writeOperation

public void writeOperation()
                    throws java.io.IOException
Write operation.

Throws:
java.io.IOException - Signals that an I/O exception has occurred.