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

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

public class UDPConnectionHandler
extends java.lang.Object

The Class UDPConnectionHandler.


Field Summary
 int aliveTime
          The alive time.
 java.net.InetSocketAddress connectedAddress
          The connected address.
 java.nio.channels.DatagramChannel datagramChannel
          The datagram channel.
 java.nio.ByteBuffer readBuffer
          The write buffer.
 java.nio.ByteBuffer writeBuffer
          The write buffer.
 
Constructor Summary
UDPConnectionHandler(int bufferSize)
          Instantiates a new UDP connection handler.
 
Method Summary
 void bind(java.nio.channels.Selector selector, int localPort)
          Bind.
 void close()
          Close.
 void connect(java.nio.channels.Selector selector, java.net.InetSocketAddress remoteAddress)
          Connect.
 boolean needsKeepAlive()
          Needs keep alive.
 java.net.InetSocketAddress readFromAddress()
          Read from address.
 java.lang.Object readObject(ConnectionHandler connectionHandler)
          Read object.
 int send(ConnectionHandler connectionHandler, java.lang.Object object, java.net.SocketAddress address)
          Send.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

aliveTime

public int aliveTime
The alive time.


connectedAddress

public java.net.InetSocketAddress connectedAddress
The connected address.


datagramChannel

public java.nio.channels.DatagramChannel datagramChannel
The datagram channel.


readBuffer

public final java.nio.ByteBuffer readBuffer
The write buffer.


writeBuffer

public final java.nio.ByteBuffer writeBuffer
The write buffer.

Constructor Detail

UDPConnectionHandler

public UDPConnectionHandler(int bufferSize)
Instantiates a new UDP connection handler.

Parameters:
bufferSize - the buffer size
Method Detail

bind

public void bind(java.nio.channels.Selector selector,
                 int localPort)
          throws java.io.IOException
Bind.

Parameters:
selector - the selector
localPort - the local port
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.InetSocketAddress remoteAddress)
             throws java.io.IOException
Connect.

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

needsKeepAlive

public boolean needsKeepAlive()
Needs keep alive.

Returns:
true, if successful

readFromAddress

public java.net.InetSocketAddress readFromAddress()
                                           throws java.io.IOException
Read from address.

Returns:
the inet socket address
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

readObject

public java.lang.Object readObject(ConnectionHandler connectionHandler)
                            throws SerializationException
Read object.

Parameters:
connectionHandler - the connection handler
Returns:
the object
Throws:
SerializationException - the serialization exception

send

public int send(ConnectionHandler connectionHandler,
                java.lang.Object object,
                java.net.SocketAddress address)
         throws java.io.IOException,
                SerializationException
Send.

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