From 8faa62c1695acd636260ed5f3b426db4c2f2e652 Mon Sep 17 00:00:00 2001 From: "Jonguk. Lim" Date: Fri, 27 Sep 2024 18:30:55 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20NICE=20CI=20=EC=86=8C=EC=BC=93=20?= =?UTF-8?q?=ED=86=B5=EC=8B=A0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/support/NiceCiApiService.java | 58 ++++++++++++------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/src/main/java/cokr/xit/ens/modules/nice/service/support/NiceCiApiService.java b/src/main/java/cokr/xit/ens/modules/nice/service/support/NiceCiApiService.java index 3601347..a6f70be 100644 --- a/src/main/java/cokr/xit/ens/modules/nice/service/support/NiceCiApiService.java +++ b/src/main/java/cokr/xit/ens/modules/nice/service/support/NiceCiApiService.java @@ -91,29 +91,43 @@ public class NiceCiApiService { try (Socket socket = new Socket(HOST, PORT); // 서버에 연결 BufferedWriter out = new BufferedWriter( - new OutputStreamWriter(socket.getOutputStream(), Charset.forName("EUC-KR"))); + new OutputStreamWriter(socket.getOutputStream(), Charset.forName("EUC-KR")));){ //new OutputStreamWriter(socket.getOutputStream())); - BufferedReader in = new BufferedReader( - new InputStreamReader(socket.getInputStream(), Charset.forName("EUC-KR")))) { - - socket.setSoTimeout(TIMEOUT); // 읽기 타임아웃 설정 - - out.write(binTxt); - // FIXME: 테스트 소켓서버 통신을 위해 임시로 추가 : 테스트 완료후 제거 - out.write("\nEXIT"); - - out.newLine(); - out.flush(); - - String message; - StringBuffer sb = new StringBuffer(); - while((message = in.readLine()) != null) { - sb.append(message); - }; - rtnMsg = sb.toString(); - System.out.println("=============>>>서버 응답(EUC-KR로 읽어온 값)<<<===================================="); - System.out.println(rtnMsg); - System.out.println("=============>>>서버 응답(EUC-KR로 읽어온 값)<<<===================================="); + //BufferedReader in = new BufferedReader( + // new InputStreamReader(socket.getInputStream(), Charset.forName("EUC-KR")))) { + //InputStreamReader in = new InputStreamReader(socket.getInputStream(), Charset.forName("EUC-KR")){ + try { + InputStreamReader in = new InputStreamReader(socket.getInputStream(), Charset.forName("EUC-KR")); + socket.setSoTimeout(TIMEOUT); // 읽기 타임아웃 설정 + + out.write(binTxt); + // FIXME: 테스트 소켓서버 통신을 위해 임시로 추가 : 테스트 완료후 제거 + out.write("\nEXIT"); + + out.newLine(); + out.flush(); + + StringBuffer sb = new StringBuffer(); + //String message; + //while ((message = in.readLine()) != null) { + // sb.append(message); + //}; + + char[] chars = new char[4096]; + //in.read(chars); + + while((in.read(chars) != -1)) { + sb.append(new String(chars)); + } + + rtnMsg = sb.toString(); + System.out.println("=============>>>서버 응답(EUC-KR로 읽어온 값)<<<===================================="); + System.out.println(rtnMsg); + System.out.println("=============>>>서버 응답(EUC-KR로 읽어온 값)<<<===================================="); + in.close(); + } catch (Exception e) { + throw new RuntimeException(e); + } } catch (SocketTimeoutException e) { // 타임아웃 발생 시 처리 log.error("NICE CI Socket 서버 응답 시간 초과: " + e.getMessage());