|
|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
package com.zhehekeji.web.service.sick;
|
|
|
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.net.InetSocketAddress;
|
|
|
|
|
@ -13,6 +15,8 @@ import java.nio.charset.StandardCharsets;
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class SickSocket {
|
|
|
|
|
|
|
|
|
|
private static final Logger tcpLogger = LoggerFactory.getLogger("sick");
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
String code = readOCR("192.168.8.236", 2002);
|
|
|
|
|
System.out.println(code);
|
|
|
|
|
@ -29,10 +33,12 @@ public class SickSocket {
|
|
|
|
|
writeCmd(os);
|
|
|
|
|
is = socket.getInputStream();
|
|
|
|
|
code = read(is);
|
|
|
|
|
tcpLogger.info(code);
|
|
|
|
|
if(code!= null){
|
|
|
|
|
code = code.replace("\\n","");
|
|
|
|
|
}
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
tcpLogger.error("sick time out,ip:{},info:{}",ip,e);
|
|
|
|
|
log.error("sick time out,ip:{},info:{}",ip,e);
|
|
|
|
|
}finally {
|
|
|
|
|
if(os != null){
|
|
|
|
|
@ -63,6 +69,7 @@ public class SickSocket {
|
|
|
|
|
String startCmd = "start";
|
|
|
|
|
byte[]bytes = startCmd.getBytes(StandardCharsets.UTF_8);
|
|
|
|
|
os.write(bytes);
|
|
|
|
|
tcpLogger.info(startCmd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static String read(InputStream inStream) throws IOException {
|
|
|
|
|
|