From 725214c077d58faacd69aa1f1eceb41cfde30698 Mon Sep 17 00:00:00 2001 From: seungtaekhong Date: Sat, 13 Jan 2024 18:13:22 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20Socket=20=ED=83=80=EC=9E=84=EC=95=84?= =?UTF-8?q?=EC=9B=83=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PathPal/domain/inference/service/SocketClient.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/solution/gdsc/PathPal/domain/inference/service/SocketClient.java b/src/main/java/solution/gdsc/PathPal/domain/inference/service/SocketClient.java index bafec9a..fc4456b 100644 --- a/src/main/java/solution/gdsc/PathPal/domain/inference/service/SocketClient.java +++ b/src/main/java/solution/gdsc/PathPal/domain/inference/service/SocketClient.java @@ -23,6 +23,7 @@ public class SocketClient { private Socket socket; private BufferedInputStream bis; private BufferedOutputStream bos; + private DataOutputStream dataOutputStream; public SocketClient(String hostName, int port, int timeout) { this.port = port; @@ -44,7 +45,7 @@ private void socketConnect() { } this.socket = new Socket(); try { - this.socket.setSoTimeout(timeout); + this.socket.setSoTimeout(timeout * 10); } catch (IOException e) { } @@ -53,22 +54,23 @@ private void socketConnect() { //this.socket.connect(new InetSocketAddress(hostName, port)); this.bos = new BufferedOutputStream(socket.getOutputStream()); this.bis = new BufferedInputStream(socket.getInputStream()); + this.dataOutputStream = new DataOutputStream(bos); } catch (IOException e) { System.out.println("소켓 연결 실패. 프로그램을 종료합니다."); System.exit(1); } + System.out.println("소켓 연결 성공"); } public List inferenceImage(byte[] file) { try { // 1. Send File Size System.out.println("파일 사이즈 전송:" + file.length); - DataOutputStream dataOutputStream = new DataOutputStream(bos); dataOutputStream.writeInt(file.length); bos.flush(); // 2. receive data - int k = bis.read(readByteArray); + bis.read(readByteArray); // 3. send image System.out.println("이미지 전송 " + file.length);