How does a client receive response from an ISO server using the j8583 library.
One of the problems is to dynamically determine the size of the incoming ISO message. As a result i have resorted to using fixed message size, for testing purposes.
Another issue is that, depending on the size of my byte array, I do not get the full ISO message response sent from an ISO Server. If the size of the byte array is 321(321 is the size of the incoming message), it takes forever for the message to be read. On the other hand, an incomplete ISO message is read if the size of the byte array is smaller than 321.
find below a sample of the code
while (sock != null && sock.isConnected()) {
out.print("
while condition is true");
sock.getInputStream().read(lenbuf);
int size = ( (lenbuf[0] & 0xff) << 8) | (lenbuf[1] & 0xff) ;
buf = new byte[size];
int t = sock.getInputStream().read(buf);
out.println(t+" "+size+" "+buf.length);
if (sock.getInputStream().read(buf) != -1) {
try {
out.print("YAYYYYYY");
out.println(String.format("abt to parse"));
IsoMessage resp = mfact.parseMessage(buf,4);
String respHeader = mfact.getIsoHeader(0x210);
out.println("<br/>iso header"+respHeader);
out.println(String.format("Read response %s conf %s: %s",resp.getField(11), resp.getField(38), new String(buf)));
pending.remove(resp.getField(11).toString());
} catch (Exception ex) {
out.println("Parsing response" + ex.getMessage());
}
} else {
out.println("THE BUF GUYS \n");
for (int i = 0; i < buf.length; i++) {
out.println(buf[i]+"\n");
}
out.println("THIS IS THE SIZE " + size + " AND BUF IS " + buf.length);
pending.clear();
return;
}
}
Anonymous
this is what i have, not sure if is the best