aboutsummaryrefslogtreecommitdiff
path: root/src/Ivy.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/Ivy.java')
-rwxr-xr-xsrc/Ivy.java25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/Ivy.java b/src/Ivy.java
index 2a0a6d5..6f00062 100755
--- a/src/Ivy.java
+++ b/src/Ivy.java
@@ -1,5 +1,5 @@
/**
- * a software bus package
+ * The Ivy software bus main class
*
* @author Yannick Jestin <a
* href="mailto:yannick.jestin@enac.fr">yannick.jestin&enac.fr</a>
@@ -16,6 +16,8 @@
*
* CHANGELOG:
* 1.2.16
+ * - fixes a concurent exception in the stop() method (no more
+ * removeClient , triggered in the SendNow test)
* - now uses the synchronized wrappers of the Java API for all collections
* 1.2.15
* - allows the fine tuning of the IvyClient socket buffersize using
@@ -139,12 +141,6 @@ import java.util.StringTokenizer;
public class Ivy implements Runnable {
/**
- * the protocol version number.
- */
- public static final int PROTOCOLVERSION = 3;
- public static final int PROTOCOLMINIMUM = 3;
- private static final int GRACEDELAY = 200; // in milliseconds
- /**
* the port for the UDP rendez vous, if none is supplied.
*/
public static final int DEFAULT_PORT = 2010;
@@ -165,7 +161,13 @@ public class Ivy implements Runnable {
* invoked with -DIVY_DEBUG
*/
public static final String LIBVERSION ="1.2.16";
- public static final int TIMEOUTLENGTH = 1000;
+
+ /*
+ * private fields
+ */
+ private static final int GRACEDELAY = 200; // in milliseconds, the time to wait if we want to join a bus, send a message, and quit
+ static final int TIMEOUTLENGTH = 1000;
+
private String appName;
private int applicationPort; /* Application port number */
@@ -344,7 +346,7 @@ public class Ivy implements Runnable {
} catch (IOException e) {
throw new IvyException("can't open TCP service socket " + e );
}
- traceDebug("lib: " + LIBVERSION + " protocol: " + PROTOCOLVERSION + " TCP service open on port " + applicationPort);
+ traceDebug("lib: " + LIBVERSION + " protocol: " + Protocol.PROTOCOLVERSION + " TCP service open on port " + applicationPort);
Domain[] d = parseDomains(db);
if (d.length == 0) throw new IvyException("no domain found in " + db);
@@ -353,6 +355,7 @@ public class Ivy implements Runnable {
for (Domain dom: d) watchers.addElement(new IvyWatcher(this , dom.domainaddr , dom.port));
serverThread = new Thread(this);
serverThread.setName("Ivy TCP server Thread");
+ serverThread.setDaemon(true);
serverThread.start();
// sends the broadcasts and listen to incoming connexions
for (IvyWatcher iw: watchers) iw.doStart();
@@ -421,7 +424,7 @@ public class Ivy implements Runnable {
for (IvyClient c : clients.values()) {
if (c != null) {
c.close(true);
- removeClient(c);
+ // removeClient(c); // useless ?
}
}
}
@@ -488,7 +491,7 @@ public class Ivy implements Runnable {
traceDebug("sending "+message);
String msg = message;
if (doProtectNewlines) msg = IvyClient.encode(message);
- else if ( (msg.indexOf(IvyClient.newLineChar) != -1)||(msg.indexOf(IvyClient.endArgChar) != -1))
+ else if ( (msg.indexOf(Protocol.NEWLINE) != -1)||(msg.indexOf(Protocol.ENDARG) != -1))
throw new IvyException("newline character not allowed in Ivy messages");
synchronized (clients) {
for ( IvyClient client : clients.values()) if (client != null) count += client.sendMsg(msg);