X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Fserial%2FServer.java;h=b2771863f9be0aab58626c50f39e768a88d3e721;hb=b08aa70e2045404d935895fafac6d2fb69f9b92f;hp=f2a01c5deaa6a2db2f970d041f5b0b8178444e2c;hpb=f157aed840bdd5b8ef04902d2326d916f71139da;p=fanfix.git diff --git a/src/be/nikiroo/utils/serial/Server.java b/src/be/nikiroo/utils/serial/Server.java index f2a01c5..b277186 100644 --- a/src/be/nikiroo/utils/serial/Server.java +++ b/src/be/nikiroo/utils/serial/Server.java @@ -125,19 +125,38 @@ abstract public class Server implements Runnable { * Start the server (listen on the network for new connections). *

* Can only be called once. + *

+ * This call is synchronous. */ public void start() { + start(true); + } + + /** + * Start the server (listen on the network for new connections). + *

+ * Can only be called once. + * + * @param wait + * TRUE for synchronous, FALSE for asynchronous + */ + public void start(boolean wait) { boolean ok = false; synchronized (lock) { if (!started && ss != null) { - started = true; - new Thread(this).start(); ok = true; + started = true; + if (!wait) { + new Thread(this).start(); + } } } if (ok) { tracer.trace(name + ": server started on port " + port); + if (wait) { + run(); + } } else if (ss == null) { tracer.error(name + ": cannot start server on port " + port + ", it has already been used");