mail.communication.inet
Class UDP

java.lang.Object
  extended by mail.communication.inet.UDP

public class UDP
extends java.lang.Object


Nested Class Summary
static class UDP.UDPException
           
 
Field Summary
(package private)  int anz
           
(package private)  java.util.HashSet<java.lang.Integer> arrive
           
static int CPACKAGE
          The UDP packet contains a CPackage -> there may be more packages following
static int CPACKAGE_HEADER
           
(package private)  long creation
           
(package private)  byte[] data
           
static int DISCARD_TIME
          the time after which missing UDP-packets are considered lost
static int ECHO
          content for PING : ECHO package received
static int HOLE_PUNCH_REQUEST
          The UDP packet is a hole punch request
(package private)  byte[] id
           
static int IP_REQUEST
          content for PING : want to know my IP
static int IPv4
          the used IP-Address is of type IPv4
static int IPv6
          the used IP-Address is of type IPv6
static int NO_REPLY
          content for PING : no package received
static int PING
          The UDP packet is a ping OR: content for PING : PING package received
(package private)  int port
           
static int PUNCH_HOLE
          The UDP packet is a command to punch a UDP hole
static int PUNCH_PERFORMED
          content for PING : punch was performed
static int PUNCH_REJECTED
          content for PING : punch will not be performed
private static java.util.Random random
           
static int REQUEST_FAILED
          content for PING : punch request failed to have any effect
static int REQUEST_PERFORMED
          content for PING : punch request will be performed
(package private)  java.net.InetAddress sender
           
static int SPLIT_SIZE
          the max. size in bytes of created UDP-Packets
(package private)  int type
           
static int UNSUPPORTED
          Reply to an unsupported package type
static int YOUR_IP
          The UDP packet is the answer to an IP request
 
Constructor Summary
UDP(java.net.DatagramPacket dp)
           
 
Method Summary
 void add(java.net.DatagramPacket dp)
           
static java.net.DatagramPacket[] build(byte[] out, InetAddress address)
          split a given byte[] into DatagramPackets
static java.net.DatagramPacket build(int type, InetAddress address, InetAddress action)
           
 boolean finished()
           
 InetAddress getActionAddress()
           
 java.io.InputStream getInput()
           
 int getResponse()
           
 InetAddress getSender()
           
 int getType()
           
static java.net.DatagramPacket ping(int echo, InetAddress address)
          sends a ping, or answers a ping.
 boolean tooOld()
           
 java.lang.String toString()
           
static java.net.DatagramPacket unsupported(UDP unsupported)
           
 boolean useable(java.net.DatagramPacket dp)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SPLIT_SIZE

public static final int SPLIT_SIZE
the max. size in bytes of created UDP-Packets

See Also:
Constant Field Values

CPACKAGE_HEADER

public static final int CPACKAGE_HEADER
See Also:
Constant Field Values

UNSUPPORTED

public static final int UNSUPPORTED
Reply to an unsupported package type

See Also:
Constant Field Values

CPACKAGE

public static final int CPACKAGE
The UDP packet contains a CPackage -> there may be more packages following

See Also:
Constant Field Values

PING

public static final int PING
The UDP packet is a ping OR: content for PING : PING package received

See Also:
Constant Field Values

HOLE_PUNCH_REQUEST

public static final int HOLE_PUNCH_REQUEST
The UDP packet is a hole punch request

See Also:
Constant Field Values

PUNCH_HOLE

public static final int PUNCH_HOLE
The UDP packet is a command to punch a UDP hole

See Also:
Constant Field Values

YOUR_IP

public static final int YOUR_IP
The UDP packet is the answer to an IP request

See Also:
Constant Field Values

IPv4

public static final int IPv4
the used IP-Address is of type IPv4

See Also:
Constant Field Values

IPv6

public static final int IPv6
the used IP-Address is of type IPv6

See Also:
Constant Field Values

NO_REPLY

public static final int NO_REPLY
content for PING : no package received

See Also:
Constant Field Values

ECHO

public static final int ECHO
content for PING : ECHO package received

See Also:
Constant Field Values

PUNCH_PERFORMED

public static final int PUNCH_PERFORMED
content for PING : punch was performed

See Also:
Constant Field Values

PUNCH_REJECTED

public static final int PUNCH_REJECTED
content for PING : punch will not be performed

See Also:
Constant Field Values

REQUEST_PERFORMED

public static final int REQUEST_PERFORMED
content for PING : punch request will be performed

See Also:
Constant Field Values

REQUEST_FAILED

public static final int REQUEST_FAILED
content for PING : punch request failed to have any effect

See Also:
Constant Field Values

IP_REQUEST

public static final int IP_REQUEST
content for PING : want to know my IP

See Also:
Constant Field Values

DISCARD_TIME

public static final int DISCARD_TIME
the time after which missing UDP-packets are considered lost

See Also:
Constant Field Values

random

private static final java.util.Random random

type

int type

data

byte[] data

sender

java.net.InetAddress sender

port

int port

creation

long creation

id

byte[] id

anz

int anz

arrive

java.util.HashSet<java.lang.Integer> arrive
Constructor Detail

UDP

public UDP(java.net.DatagramPacket dp)
Method Detail

build

public static java.net.DatagramPacket[] build(byte[] out,
                                              InetAddress address)
split a given byte[] into DatagramPackets

Parameters:
out - the byte[] to split
address - the address to encode into the DatagramPacketS
Returns:
the created DatagramPacketS

ping

public static java.net.DatagramPacket ping(int echo,
                                           InetAddress address)
sends a ping, or answers a ping.

Parameters:
echo - either ECHO or PING, use ECHO as response for PING + Responses for UDP-Hole-Punching
address -
Returns:

build

public static java.net.DatagramPacket build(int type,
                                            InetAddress address,
                                            InetAddress action)
                                     throws UDP.UDPException
Throws:
UDP.UDPException

unsupported

public static java.net.DatagramPacket unsupported(UDP unsupported)

tooOld

public boolean tooOld()

add

public void add(java.net.DatagramPacket dp)
         throws UDP.UDPException
Throws:
UDP.UDPException

useable

public boolean useable(java.net.DatagramPacket dp)

finished

public boolean finished()

getInput

public java.io.InputStream getInput()
                             throws UDP.UDPException
Throws:
UDP.UDPException

getType

public int getType()

getSender

public InetAddress getSender()

getActionAddress

public InetAddress getActionAddress()
                             throws UDP.UDPException
Throws:
UDP.UDPException

getResponse

public int getResponse()
                throws UDP.UDPException
Throws:
UDP.UDPException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object