From c5fc6ad7244c547f622def58e83f8a0f8f513d9f Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <xltys1995> Date: 星期六, 14 十一月 2020 15:54:17 +0800 Subject: [PATCH] # --- src/main/java/com/zy/core/thread/BarcodeThread.java | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/zy/core/thread/BarcodeThread.java b/src/main/java/com/zy/core/thread/BarcodeThread.java index cd3848b..6555d84 100644 --- a/src/main/java/com/zy/core/thread/BarcodeThread.java +++ b/src/main/java/com/zy/core/thread/BarcodeThread.java @@ -12,6 +12,7 @@ import java.net.InetSocketAddress; import java.net.Socket; import java.net.SocketAddress; +import java.net.SocketTimeoutException; /** * 鏉$爜鎵弿浠嚎绋� @@ -37,12 +38,13 @@ connect(); while (true) { try { - write("T".getBytes(), "T".length()); - byte[] read = read(11, 5); +// write("T".getBytes(), "T".length()); + byte[] read = read(11, 200); if (null != read) { barcode = new String(read); } Thread.sleep(100); + } catch (SocketTimeoutException ignore) { } catch (Exception e) { e.printStackTrace(); } @@ -98,7 +100,7 @@ if (socket == null) { return null; } - socket.setSoTimeout(timeOut * 1000); + socket.setSoTimeout(timeOut); byte[] bytes = new byte[bufferSize]; int len = dataInputStream.read(bytes); byte[] tempBytes = null; -- Gitblit v1.9.1