|
|
|
@ -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());
|
|
|
|
|