I am sending byte[] data through a socket from an MDB in Websphere to a stand alone socket server. When I do a display of the size of the data on the MDB "client" end it shows that the size of the field is 2807 bytes. On the server side it display 12 bytes. When I display the contents of the field on either side they are identical. I have included my code snippets.
client side (MDB):
PrintWriter out = null;
BufferedOutputStream out1 = null;
BufferedReader in = null;
String lineRead = null;
String input = " ";
byte[] compressedData = null;
try{
out1 = new BufferedOutputStream(soc.getOutputStream());
out = new PrintWriter(out1,true);
in = new BufferedReader(new InputStreamReader(soc.getInputStream()));
out.println(rawData + "\n");
out.flush();
while ((lineRead = in.readLine()) != null){
if (lineRead.length() == 0) break;
input = input + lineRead.getBytes();
logger.debug("this is what's in input " + input);
}
if (input == null){
logger.debug("input is null");
String input1 = "stuff";
compressedData = input1.getBytes();
}else{
logger.debug("Here is the stuff" + input);
compressedData = input.getBytes();
}
}catch(UnknownHostException e){
e.printStackTrace();
}
catch(IOException e){
e.printStackTrace();
}
finally {
try{
logger.debug("closing sockets and streams");
out.close();
out1.close();
in.close();
}catch(Exception e){
e.printStackTrace();
}
}
return compressedData;
}
server side (stand alone socket server)
PrintWriter out = null;
BufferedReader in = null;
byte[] compressedData = null;
try{
out = new PrintWriter(new BufferedOutputStream(server.getOutputStream()));
in = new BufferedReader(new InputStreamReader(server.getInputStream()));
while ((inputLine = in.readLine()) != null ){
if (inputLine.length() == 0) break;
outputLine = outputLine + inputLine;
System.out.println("Here's the old data array: " + outputLine.toString() + " " + outputLine.length());
newDataArray = outputLine.getBytes();
}
out.println("I am out of here. \n");
out.flush();
}catch(UnknownHostException e){
e.printStackTrace();
}
catch(IOException e){
e.printStackTrace();
}
finally {
try{
System.out.println("closing sockets and streams");
out.close();
in.close();
//outData.close();
server.close();
}catch(Exception e){
e.printStackTrace();
}
}
return compressedData;