local.net
Class UdpRelay

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--local.net.UdpRelay
All Implemented Interfaces:
java.lang.Runnable

public class UdpRelay
extends java.lang.Thread

UdpRelay implements a direct UDP datagram relay agent. It receives UDP packets at a local port and relays them toward a remote UDP socket (destination address/port).


Field Summary
static int MAX_PKT_SIZE
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
UdpRelay(int local_port, java.lang.String dest_addr, int dest_port, int alive_time, UdpRelayListener listener)
          Creates a new UDP relay and starts it.
UdpRelay(int local_port, java.lang.String dest_addr, int dest_port, UdpRelayListener listener)
          Creates a new UDP relay and starts it.
 
Method Summary
 int getLocalPort()
          Gets the local receiver/sender port
 int getSoTimeout()
          Gets the maximum time that the UDP relay can remain active after been halted
 void halt()
          Stops the UDP relay
 boolean isRunning()
          Whether the UDP relay is running
static void main(java.lang.String[] args)
          The main method.
 void run()
          Redirect packets received from remote source addr/port to destination addr/port
 UdpRelay setDestAddress(java.lang.String dest_addr)
          Sets a new destination address
 UdpRelay setDestPort(int dest_port)
          Sets a new destination port
 void setSoTimeout(int so_to)
          Sets the maximum time that the UDP relay can remain active after been halted
 java.lang.String toString()
          Gets a String representation of the Object
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_PKT_SIZE

public static final int MAX_PKT_SIZE
Constructor Detail

UdpRelay

public UdpRelay(int local_port,
                java.lang.String dest_addr,
                int dest_port,
                UdpRelayListener listener)
Creates a new UDP relay and starts it.

The UdpRelay remains active until method halt() is called.


UdpRelay

public UdpRelay(int local_port,
                java.lang.String dest_addr,
                int dest_port,
                int alive_time,
                UdpRelayListener listener)
Creates a new UDP relay and starts it.

The UdpRelay will automatically stop after alive_time seconds of idle time (i.e. without receiving UDP datagrams)

Method Detail

getLocalPort

public int getLocalPort()
Gets the local receiver/sender port

setDestAddress

public UdpRelay setDestAddress(java.lang.String dest_addr)
Sets a new destination address

setDestPort

public UdpRelay setDestPort(int dest_port)
Sets a new destination port

isRunning

public boolean isRunning()
Whether the UDP relay is running

halt

public void halt()
Stops the UDP relay

setSoTimeout

public void setSoTimeout(int so_to)
Sets the maximum time that the UDP relay can remain active after been halted

getSoTimeout

public int getSoTimeout()
Gets the maximum time that the UDP relay can remain active after been halted

run

public void run()
Redirect packets received from remote source addr/port to destination addr/port
Overrides:
run in class java.lang.Thread

toString

public java.lang.String toString()
Gets a String representation of the Object
Overrides:
toString in class java.lang.Thread

main

public static void main(java.lang.String[] args)
The main method.