Skip to content

Commit

Permalink
API.java allow partial reads
Browse files Browse the repository at this point in the history
  • Loading branch information
kanoi committed Feb 14, 2013
1 parent c432c65 commit 00be617
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Binary file modified API.class
Binary file not shown.
13 changes: 11 additions & 2 deletions API.java
Expand Up @@ -76,6 +76,7 @@ public void display(String result) throws Exception

public void process(String cmd, InetAddress ip, int port) throws Exception
{
StringBuffer sb = new StringBuffer();
char buf[] = new char[MAXRECEIVESIZE];
int len = 0;

Expand All @@ -89,7 +90,15 @@ public void process(String cmd, InetAddress ip, int port) throws Exception
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();
}
Expand All @@ -100,7 +109,7 @@ public void process(String cmd, InetAddress ip, int port) throws Exception
return;
}

String result = new String(buf, 0, len);
String result = sb.toString();

System.out.println("Answer='"+result+"'");

Expand Down

0 comments on commit 00be617

Please sign in to comment.