import java.io.OutputStreamWriter;
import java.net.Socket;
+import javax.net.ssl.SSLException;
+
import be.nikiroo.utils.Version;
import be.nikiroo.utils.serial.Exporter;
import be.nikiroo.utils.serial.Importer;
private OutputStreamWriter out;
private boolean contentToSend;
+ private long bytesReceived;
+ private long bytesSent;
+
/**
* Method that will be called when an action is performed on either the
* client or server this {@link ConnectAction} represent.
return version;
}
+ /**
+ * 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;
+ }
+
/**
* Actually start the process (this is synchronous).
*/
in = null;
}
} catch (Exception e) {
+ if (e instanceof SSLException) {
+ String ciphers = "";
+ for (String cipher : Server.getAnonCiphers()) {
+ if (!ciphers.isEmpty()) {
+ ciphers += ", ";
+ }
+ ciphers += cipher;
+ }
+
+ e = new SSLException("SSL error (available SSL ciphers: "
+ + ciphers + ")", e);
+ }
+
onError(e);
} finally {
try {
protected Object sendObject(Object data) throws IOException,
NoSuchFieldException, NoSuchMethodException, ClassNotFoundException {
synchronized (lock) {
- String rep = sendString(new Exporter().append(data).toString(true));
+ String rep = sendString(new Exporter().append(data).toString(true,
+ true));
if (rep != null) {
return new Importer().read(rep).getValue();
}
synchronized (lock) {
out.write(line);
out.write("\n");
+ bytesSent += line.length() + 1;
if (server) {
out.flush();
contentToSend = false;
}
- return in.readLine();
+ String line = in.readLine();
+ if (line != null) {
+ bytesReceived += line.length();
+ }
+
+ return line;
}
return null;