feat: NICE CI 소켓 통신 추가

dev
Jonguk. Lim 2 months ago
parent dca46fa392
commit 8faa62c169

@ -91,29 +91,43 @@ public class NiceCiApiService {
try (Socket socket = new Socket(HOST, PORT); // 서버에 연결 try (Socket socket = new Socket(HOST, PORT); // 서버에 연결
BufferedWriter out = new BufferedWriter( BufferedWriter out = new BufferedWriter(
new OutputStreamWriter(socket.getOutputStream(), Charset.forName("EUC-KR"))); new OutputStreamWriter(socket.getOutputStream(), Charset.forName("EUC-KR")));){
//new OutputStreamWriter(socket.getOutputStream())); //new OutputStreamWriter(socket.getOutputStream()));
BufferedReader in = new BufferedReader( //BufferedReader in = new BufferedReader(
new InputStreamReader(socket.getInputStream(), Charset.forName("EUC-KR")))) { // new InputStreamReader(socket.getInputStream(), Charset.forName("EUC-KR")))) {
//InputStreamReader in = new InputStreamReader(socket.getInputStream(), Charset.forName("EUC-KR")){
socket.setSoTimeout(TIMEOUT); // 읽기 타임아웃 설정 try {
InputStreamReader in = new InputStreamReader(socket.getInputStream(), Charset.forName("EUC-KR"));
out.write(binTxt); socket.setSoTimeout(TIMEOUT); // 읽기 타임아웃 설정
// FIXME: 테스트 소켓서버 통신을 위해 임시로 추가 : 테스트 완료후 제거
out.write("\nEXIT"); out.write(binTxt);
// FIXME: 테스트 소켓서버 통신을 위해 임시로 추가 : 테스트 완료후 제거
out.newLine(); out.write("\nEXIT");
out.flush();
out.newLine();
String message; out.flush();
StringBuffer sb = new StringBuffer();
while((message = in.readLine()) != null) { StringBuffer sb = new StringBuffer();
sb.append(message); //String message;
}; //while ((message = in.readLine()) != null) {
rtnMsg = sb.toString(); // sb.append(message);
System.out.println("=============>>>서버 응답(EUC-KR로 읽어온 값)<<<===================================="); //};
System.out.println(rtnMsg);
System.out.println("=============>>>서버 응답(EUC-KR로 읽어온 값)<<<===================================="); 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) { } catch (SocketTimeoutException e) {
// 타임아웃 발생 시 처리 // 타임아웃 발생 시 처리
log.error("NICE CI Socket 서버 응답 시간 초과: " + e.getMessage()); log.error("NICE CI Socket 서버 응답 시간 초과: " + e.getMessage());

Loading…
Cancel
Save