Here is some master reciever code for DAMMPclass ResultsReceiver implements Runnable, CommonConstants {

// Master Control Program, the parent to give the results back to.

JobMaster mcp; // callback hook

int udpPortNum; // the UDP port this receiver listens on.

int resultsSize; // # of bytes in a results packet
int receiverID; // a tag to uniquely ID this thread

DatagramSocket dgSocket; // this thread's receive socket

static PrintStream o = System.out; // convenient shorthand

//-------------------------------------------------------------------
// ResultsReceiver Constructor
//-------------------------------------------------------------------
public ResultsReceiver ( int receiverID, int resultsSize, JobMaster mcp ) {

this.udpPortNum = RESULTS_BASE_UDP_PORT + receiverID;
this.resultsSize= resultsSize;
this.receiverID = receiverID;
this.mcp = mcp;

try {
dgSocket = new DatagramSocket(udpPortNum);

if (dgSocket == null) {
throw new SocketException("Null socket!");
}
} catch (SocketException noSock) {
o.println("Failed to create ResultsReceiver because " +
"could not create its UDP receive port: " + udpPortNum);
return;
} catch (IOException badIO) {
o.println("IO Exception in ResultsReceiver constructor." + badIO);
}

new Thread(this).start(); // continue running in run()
}

//-------------------------------------------------------------------
// ResultsReceiver infinite loop:
// - catch result packet from applet
// - pass results up to JobMaster
//-------------------------------------------------------------------
public void run () {
byte[] results = new byte[resultsSize];

while(true) {
DatagramPacket dg = new DatagramPacket(results, resultsSize);

try {
dgSocket.receive(dg);
} catch (IOException rcvError) {
continue; // just ignore and wait for a new packet.
}

mcp.collateResults( dg.getData(), receiverID );
}
}

} // End of Class ResultsReceiver