try {
server = (ServerSocketConnection) Connector.open("socket://:37");
Runnable r = new Runnable() {
public void run() {
while (true) {
try {
StreamConnection conn = server.acceptAndOpen();
Date now = new Date();
long msSince1970 = now.getTime();
long secondsSince1900 = msSince1970/1000L + differenceBetweenEpochs;
DataOutputStream out = conn.openDataOutputStream();
// write the low order four bytes
out.write( (int) ((secondsSince1900 >>> 24) & 0xFFL));
out.write( (int) ((secondsSince1900 >>> 16) & 0xFFL));
out.write( (int) ((secondsSince1900 >>> 8) & 0xFFL));
out.write( (int) (secondsSince1900 & 0xFFL));
out.close();
}
catch (IOException ex) {
}
}
}
};
Thread t = new Thread(r);
t.start();
}
catch (IOException ex) {
// not much we can do about this here
}