|
|
@@ -52,28 +52,35 @@ public class SocketClient { |
|
|
|
String reply=null; |
|
|
|
//输入流 |
|
|
|
InputStream is=socket.getInputStream(); |
|
|
|
BufferedReader br=new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)); |
|
|
|
//BufferedReader br=new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)); |
|
|
|
ByteArrayOutputStream swapStream = new ByteArrayOutputStream(); |
|
|
|
byte[] buff = new byte[100]; |
|
|
|
|
|
|
|
StringBuffer ackResultBuf= new StringBuffer(); |
|
|
|
//StringBuffer ackResultBuf= new StringBuffer(); |
|
|
|
//String ackHexOut = HexConvert.convertStringToHex(ackAckCheckRef); |
|
|
|
reply=br.readLine(); |
|
|
|
while(reply!=null){ |
|
|
|
//log.debug("接收服务器的信息:"+reply); |
|
|
|
//if (ackHexOut.equals(reply)) { |
|
|
|
ackResultBuf.append(reply); |
|
|
|
reply=br.readLine(); |
|
|
|
// break; |
|
|
|
//} |
|
|
|
// reply=br.readLine(); |
|
|
|
// while(reply!=null){ |
|
|
|
// //log.debug("接收服务器的信息:"+reply); |
|
|
|
// //if (ackHexOut.equals(reply)) { |
|
|
|
// ackResultBuf.append(reply); |
|
|
|
// reply=br.readLine(); |
|
|
|
// // break; |
|
|
|
// //} |
|
|
|
// } |
|
|
|
int rc = 0; |
|
|
|
while ((rc = is.read(buff, 0, 100)) > 0) { |
|
|
|
swapStream.write(buff, 0, rc); |
|
|
|
} |
|
|
|
byte[] in2b = swapStream.toByteArray(); |
|
|
|
//String ackResult = HexConvert.convertHexToString(ackResultBuf.toString()); |
|
|
|
//4.关闭资源 |
|
|
|
br.close(); |
|
|
|
swapStream.close(); |
|
|
|
is.close(); |
|
|
|
pw.close(); |
|
|
|
os.close(); |
|
|
|
//log.debug(ackResult); |
|
|
|
log.debug("接收服务器的信息:"+ackResultBuf.toString()); |
|
|
|
return ackResultBuf.toString(); |
|
|
|
log.debug("接收服务器的信息:"+in2b.toString()); |
|
|
|
return in2b.toString(); |
|
|
|
} catch (IOException e) { |
|
|
|
log.error("Socket sendCmd Error:" + e.getMessage()); |
|
|
|
return null; |
|
|
|