udt
Class UDPEndPoint

java.lang.Object
  extended by udt.UDPEndPoint

public class UDPEndPoint
extends Object

the UDPEndpoint takes care of sending and receiving UDP network packets, dispatching them to the correct UDTSession


Field Summary
static int DATAGRAM_SIZE
           
 
Constructor Summary
UDPEndPoint()
          bind to an ephemeral port on the default network interface on the machine
UDPEndPoint(DatagramSocket socket)
          create an endpoint on the given socket
UDPEndPoint(InetAddress localAddress)
          bind to any local port on the given host address
UDPEndPoint(InetAddress localAddress, int localPort)
          Bind to the given address and port
UDPEndPoint(int localPort)
          bind to the default network interface on the machine
 
Method Summary
protected  UDTSession accept(long timeout, TimeUnit unit)
          wait the given time for a new connection
 void addClientSession(Destination peer, UDTSession session)
           
 void addSession(Long destinationID, UDTSession session)
           
protected  void doReceive()
           
protected  void doSend(UDTPacket packet)
           
 InetAddress getLocalAddress()
           
 int getLocalPort()
           
 UDTSession getSession(Long destinationID)
           
 Collection<UDTSession> getSessions()
           
 void removeClientSession(Destination peer)
           
 void sendRaw(DatagramPacket p)
           
 void start()
           
 void start(boolean serverSocketModeEnabled)
          start the endpoint.
 void stop()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DATAGRAM_SIZE

public static final int DATAGRAM_SIZE
See Also:
Constant Field Values
Constructor Detail

UDPEndPoint

public UDPEndPoint(DatagramSocket socket)
create an endpoint on the given socket

Parameters:
socket - - a UDP datagram socket

UDPEndPoint

public UDPEndPoint(InetAddress localAddress)
            throws SocketException,
                   UnknownHostException
bind to any local port on the given host address

Parameters:
localAddress -
Throws:
SocketException
UnknownHostException

UDPEndPoint

public UDPEndPoint(InetAddress localAddress,
                   int localPort)
            throws SocketException,
                   UnknownHostException
Bind to the given address and port

Parameters:
localAddress -
localPort - - the port to bind to. If the port is zero, the system will pick an ephemeral port.
Throws:
SocketException
UnknownHostException

UDPEndPoint

public UDPEndPoint(int localPort)
            throws SocketException,
                   UnknownHostException
bind to the default network interface on the machine

Parameters:
localPort - - the port to bind to. If the port is zero, the system will pick an ephemeral port.
Throws:
SocketException
UnknownHostException

UDPEndPoint

public UDPEndPoint()
            throws SocketException,
                   UnknownHostException
bind to an ephemeral port on the default network interface on the machine

Throws:
SocketException
UnknownHostException
Method Detail

start

public void start(boolean serverSocketModeEnabled)
start the endpoint. If the serverSocketModeEnabled flag is true, a new connection can be handed off to an application. The application needs to call #accept() to get the socket

Parameters:
serverSocketModeEnabled -

start

public void start()

stop

public void stop()

getLocalPort

public int getLocalPort()
Returns:
the port which this client is bound to

getLocalAddress

public InetAddress getLocalAddress()
Returns:
Gets the local address to which the socket is bound

addSession

public void addSession(Long destinationID,
                       UDTSession session)

addClientSession

public void addClientSession(Destination peer,
                             UDTSession session)

removeClientSession

public void removeClientSession(Destination peer)

getSession

public UDTSession getSession(Long destinationID)

getSessions

public Collection<UDTSession> getSessions()

accept

protected UDTSession accept(long timeout,
                            TimeUnit unit)
                     throws InterruptedException
wait the given time for a new connection

Parameters:
timeout - - the time to wait
unit - - the TimeUnit
Returns:
a new UDTSession
Throws:
InterruptedException

doReceive

protected void doReceive()
                  throws IOException
Throws:
IOException

doSend

protected void doSend(UDTPacket packet)
               throws IOException
Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object

sendRaw

public void sendRaw(DatagramPacket p)
             throws IOException
Throws:
IOException


Copyright © 2013 LittleShoot. All Rights Reserved.