X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Fserial%2Fserver%2FServer.java;h=8e83d416fe7a653e5b008e2f9daf747a35ab7db1;hb=10c1713c429b19e6a44c17edf053f3c26d1b22be;hp=afceaf95323ec349825372c858b65fc95f185761;hpb=0988831f084e27de9927c1bb29e338e9263bfa42;p=nikiroo-utils.git diff --git a/src/be/nikiroo/utils/serial/server/Server.java b/src/be/nikiroo/utils/serial/server/Server.java index afceaf9..8e83d41 100644 --- a/src/be/nikiroo/utils/serial/server/Server.java +++ b/src/be/nikiroo/utils/serial/server/Server.java @@ -38,6 +38,9 @@ abstract class Server implements Runnable { private boolean exiting = false; private int counter; + private long bytesReceived; + private long bytesSent; + private TraceHandler tracer = new TraceHandler(); /** @@ -146,6 +149,24 @@ abstract class Server implements Runnable { return port; } + /** + * The total amount of bytes received. + * + * @return the amount of bytes received + */ + public long getBytesReceived() { + return bytesReceived; + } + + /** + * The total amount of bytes sent. + * + * @return the amount of bytes sent + */ + public long getBytesSent() { + return bytesSent; + } + /** * Start the server (listen on the network for new connections). *

@@ -194,16 +215,30 @@ abstract class Server implements Runnable { tracer.trace(name + ": server starting on port " + port + " (" + (ssl ? "SSL" : "plain text") + ")"); + String ciphers = ""; + for (String cipher : getAnonCiphers()) { + if (!ciphers.isEmpty()) { + ciphers += ", "; + } + ciphers += cipher; + } + while (started && !exiting) { count(1); final Socket s = ss.accept(); new Thread(new Runnable() { @Override public void run() { + ConnectActionServer action = null; try { - createConnectActionServer(s).connect(); + action = createConnectActionServer(s); + action.connect(); } finally { count(-1); + if (action != null) { + bytesReceived += action.getBytesReceived(); + bytesSent += action.getBytesSent(); + } } } }).start(); @@ -407,7 +442,7 @@ abstract class Server implements Runnable { * * @return the list of such supported ciphers */ - private static String[] getAnonCiphers() { + public static String[] getAnonCiphers() { List anonCiphers = new ArrayList(); for (String cipher : ((SSLSocketFactory) SSLSocketFactory.getDefault()) .getSupportedCipherSuites()) {