de.stz.bt.fnd
Class FND_UDPTransport

java.lang.Object
  extended byjava.lang.Thread
      extended byde.stz.bt.framework.DatagramTransport
          extended byde.stz.bt.fnd.FND_UDPTransport
All Implemented Interfaces:
java.lang.Runnable

public class FND_UDPTransport
extends DatagramTransport


Nested Class Summary
 class FND_UDPTransport.FND_MessageQueue
           
 
Field Summary
(package private)  FND_DataPointContext context
           
private  byte[] data
           
private static int DEFAULT_CENTRAL_PORT
           
private static int DEFAULT_ISLAND_PORT
           
private  FND_UDPTransport.FND_MessageQueue incomingMessageQueue
           
private  FND_InvokeIDPool invokeIDPool
           
private  FND_UDPTransport.FND_MessageQueue outgoingMessageQueue
           
private  FND_Parser parser
           
private  java.lang.Runnable senderThread
           
private  java.net.DatagramSocket socket
           
private  java.net.DatagramPacket udpPacket
           
 
Fields inherited from class de.stz.bt.framework.DatagramTransport
logger
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
FND_UDPTransport(FND_DataPointContext ctx)
          Default Constructor - listens on default port (4403 at the moment)
 
Method Summary
 void close()
          Closes the socket used by the UDPListener.
 void finalize()
          Destructor, makes sure the socket is closed, just in case.
private  void prepareReceive(int portNumber)
          Create socket and datagram packet
 FND_Datagram receive()
          This method is the main invocation point for other systems to retrieve messages
private  byte[] receivePacket()
          Wait for the next arriving UDP-packacke and return its data.
 void run()
           
 void send(FND_Datagram out)
          This method is the main invocation point to send messages
private  void sendPacket(FND_Datagram fndDatagram)
          Method used to send an FND_Datagram to the target-machine and port specified during instanciation.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_CENTRAL_PORT

private static final int DEFAULT_CENTRAL_PORT
See Also:
Constant Field Values

DEFAULT_ISLAND_PORT

private static final int DEFAULT_ISLAND_PORT
See Also:
Constant Field Values

context

FND_DataPointContext context

socket

private java.net.DatagramSocket socket

udpPacket

private java.net.DatagramPacket udpPacket

invokeIDPool

private FND_InvokeIDPool invokeIDPool

parser

private FND_Parser parser

incomingMessageQueue

private FND_UDPTransport.FND_MessageQueue incomingMessageQueue

outgoingMessageQueue

private FND_UDPTransport.FND_MessageQueue outgoingMessageQueue

senderThread

private java.lang.Runnable senderThread

data

private byte[] data
Constructor Detail

FND_UDPTransport

public FND_UDPTransport(FND_DataPointContext ctx)
                 throws java.net.SocketException,
                        java.io.IOException
Default Constructor - listens on default port (4403 at the moment)

Throws:
java.net.SocketException - If socket is already in use.
java.io.IOException - Raised if reading the socket fails.
Method Detail

prepareReceive

private void prepareReceive(int portNumber)
                     throws java.net.SocketException
Create socket and datagram packet

Parameters:
portNumber - Used by the socket.
Throws:
java.net.SocketException - If socket cannot be created.

receivePacket

private byte[] receivePacket()
                      throws java.net.SocketException
Wait for the next arriving UDP-packacke and return its data. Method is a blocking call with a timeout of

Returns:
The UDP-datagram payload, null in case of a timeout.
Throws:
java.net.SocketException - In case of a socket problem.
java.io.IOException - In case of trouble with the UDP payload.

sendPacket

private void sendPacket(FND_Datagram fndDatagram)
Method used to send an FND_Datagram to the target-machine and port specified during instanciation.

Parameters:
fndDatagram - FND_Datagram to be send.

close

public void close()
Closes the socket used by the UDPListener.


finalize

public void finalize()
Destructor, makes sure the socket is closed, just in case.


run

public void run()

send

public void send(FND_Datagram out)
This method is the main invocation point to send messages

Parameters:
out - The FND Datagram to send

receive

public FND_Datagram receive()
This method is the main invocation point for other systems to retrieve messages

Returns:
A received FND Datagram