v2.2.0.
I'm writing the external watchdog (called 'mchecker') to detect when a miner fails.
It already works with claymore and sgminer-gm, but fails with xmrstak. The reason is the output stream is not being closed, so the watchdog waits for the end of response until timeout exception is thrown.
I know I can read only a small predefined amount bytes or parse the response to detect the closing 'HTML' tag, but I want to implement general approach.
Here is how I read the response:
String result = "";
Socket s = new Socket(host, port);
s.setSoTimeout(TIMEOUT);
InputStream is = s.getInputStream();
OutputStream os = s.getOutputStream();
os.write(request.getBytes());
os.flush();
int read = 0;
int cnt = 0;
byte[] b = new byte[1024];
while ((read = is.read()) >= 0) {
if ((cnt+1) > b.length) {
b = Arrays.copyOf(b, b.length*2);
}
b[cnt++] = (byte)read;
}
result = new String(b);
v2.2.0. I'm writing the external watchdog (called 'mchecker') to detect when a miner fails. It already works with claymore and sgminer-gm, but fails with xmrstak. The reason is the output stream is not being closed, so the watchdog waits for the end of response until timeout exception is thrown. I know I can read only a small predefined amount bytes or parse the response to detect the closing 'HTML' tag, but I want to implement general approach. Here is how I read the response: