API.java allow partial reads
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
diff --git a/API.class b/API.class
index 026ab14..d506b93 100644
Binary files a/API.class and b/API.class differ
diff --git a/API.java b/API.java
index 36c1578..54dcda9 100644
--- a/API.java
+++ b/API.java
@@ -76,6 +76,7 @@ class API
public void process(String cmd, InetAddress ip, int port) throws Exception
{
+ StringBuffer sb = new StringBuffer();
char buf[] = new char[MAXRECEIVESIZE];
int len = 0;
@@ -89,7 +90,15 @@ System.out.println("Attempting to send '"+cmd+"' to "+ip.getHostAddress()+":"+po
ps.flush();
InputStreamReader isr = new InputStreamReader(socket.getInputStream());
- len = isr.read(buf, 0, MAXRECEIVESIZE);
+ while (0x80085 > 0)
+ {
+ len = isr.read(buf, 0, MAXRECEIVESIZE);
+ if (len < 1)
+ break;
+ sb.append(buf, 0, len);
+ if (buf[len-1] == '\0')
+ break;
+ }
closeAll();
}
@@ -100,7 +109,7 @@ System.out.println("Attempting to send '"+cmd+"' to "+ip.getHostAddress()+":"+po
return;
}
- String result = new String(buf, 0, len);
+ String result = sb.toString();
System.out.println("Answer='"+result+"'");