common
Class UDPHandler

java.lang.Object
  extended by java.lang.Thread
      extended by common.StoppableThread
          extended by common.TransfertSlave
              extended by common.UDPHandler
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
UDPClient, UDPListener

public class UDPHandler
extends TransfertSlave

Gestionnaire de paquets UDP.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
private static int SIZEOF_BYTE
          Taille en octets d'un byte.
private static int SIZEOF_LONG
          Taille en octets d'un long.
static long TIME_WAITING_SEND_PACKET_DEFAULT
          Temps d'attente par défaut entre l'envoi de deux paquets.
static int UDP_DATA_LENGTH
          Taille en octets des données stockées dans un paquet.
static int UDP_DATA_OFFSET
          Taille en octets de l'entête des données dans le paquet (index du début des données dans le paquet).
static int UDP_PACKET_LENGTH
          Taille en octets d'un paquet UDP.
protected  DatagramSocket udpSocket
          Socket UDP.
 
Fields inherited from class common.TransfertSlave
master
 
Fields inherited from class common.StoppableThread
quitQuery
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
protected UDPHandler(TransfertMaster master)
          Intitialise un socket UDP sur port aléatoire libre.
protected UDPHandler(TransfertMaster master, int udpPort)
          Initialise un socket UDP sur le port spécifié.
 
Method Summary
protected  void doFree()
          Libère les ressources en fermant le socket UDP.
protected  void doQuit()
          Prends les dispositions pour que le thread termine en fermant le socket UDP.
 
Methods inherited from class common.StoppableThread
free, quit
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SIZEOF_BYTE

private static final int SIZEOF_BYTE
Taille en octets d'un byte.

See Also:
Constant Field Values

SIZEOF_LONG

private static final int SIZEOF_LONG
Taille en octets d'un long.

See Also:
Constant Field Values

UDP_DATA_OFFSET

public static final int UDP_DATA_OFFSET
Taille en octets de l'entête des données dans le paquet (index du début des données dans le paquet).

See Also:
Constant Field Values

UDP_DATA_LENGTH

public static final int UDP_DATA_LENGTH
Taille en octets des données stockées dans un paquet.

See Also:
Constant Field Values

UDP_PACKET_LENGTH

public static final int UDP_PACKET_LENGTH
Taille en octets d'un paquet UDP.

See Also:
Constant Field Values

TIME_WAITING_SEND_PACKET_DEFAULT

public static final long TIME_WAITING_SEND_PACKET_DEFAULT
Temps d'attente par défaut entre l'envoi de deux paquets.

See Also:
Constant Field Values

udpSocket

protected final DatagramSocket udpSocket
Socket UDP.

Constructor Detail

UDPHandler

protected UDPHandler(TransfertMaster master)
              throws SocketStartFailure
Intitialise un socket UDP sur port aléatoire libre.

Parameters:
master - objet maître.
Throws:
SocketStartFailure - s'il est impossible de créer un socket.

UDPHandler

protected UDPHandler(TransfertMaster master,
                     int udpPort)
              throws SocketStartFailure
Initialise un socket UDP sur le port spécifié.

Parameters:
master - objet maître.
udpPort - port UDP.
Throws:
SocketStartFailure - s'il est impossible de créer un socket sur le port UDP spécifié.
Method Detail

doFree

protected final void doFree()
Libère les ressources en fermant le socket UDP.

Overrides:
doFree in class StoppableThread
See Also:
Thread.run(), StoppableThread.isFree, StoppableThread.free()

doQuit

protected void doQuit()
Prends les dispositions pour que le thread termine en fermant le socket UDP.

Overrides:
doQuit in class StoppableThread
See Also:
Thread.run(), StoppableThread.quitQuery, StoppableThread.quit()