package org.tizen.dynamicanalyzer.communicator;
import java.io.BufferedWriter;
+import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.io.RandomAccessFile;
import java.net.ServerSocket;
import org.eclipse.swt.widgets.Display;
import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
import org.tizen.dynamicanalyzer.common.DAResult;
-import org.tizen.dynamicanalyzer.common.Global;
-import org.tizen.dynamicanalyzer.common.DAState;
import org.tizen.dynamicanalyzer.common.DAResult.ErrorCode;
+import org.tizen.dynamicanalyzer.common.DAState;
+import org.tizen.dynamicanalyzer.common.Global;
import org.tizen.dynamicanalyzer.common.path.PathManager;
import org.tizen.dynamicanalyzer.constant.CommonConstants;
import org.tizen.dynamicanalyzer.handlers.CommandAction;
import org.tizen.dynamicanalyzer.workbench.SingletonFocusManager;
public class IDECommunicator implements Runnable {
- private static final int MAXBUFSIZE = 1024;
-
private static final String IDE_DA_COMMUNICATION_TYPE_1 = "STATUS";//$NON-NLS-1$
private static final String IDE_DA_COMMUNICATION_TYPE_2 = "RUN";//$NON-NLS-1$
private static final String IDE_DA_COMMUNICATION_TYPE_3 = "SOURCE";//$NON-NLS-1$
}
Thread acceptThread = new Thread("IDEAcceptThread") {//$NON-NLS-1$
- int readSize = 0;
- byte receiveBuffer[] = new byte[MAXBUFSIZE];
- InputStream in = null;
+ DataInputStream in = null;
public void run() {
Socket clientSocket = lastCommunicationIdeSocket;
while (true) {
try {
- for (int i = 0; i < receiveBuffer.length; i++) { // clear buffer
- receiveBuffer[i] = 0;
- }
- in = clientSocket.getInputStream();
+ in = new DataInputStream(clientSocket.getInputStream());
Logger.debug("IDE recvMessage Wait : "
+ ideClientSocketArray.size());
- readSize = in.read(receiveBuffer);
- if (readSize > 0) {
- lastCommunicationIdeSocket = clientSocket;
- parsingReceiveMessage(new String(receiveBuffer));
- } else {
- Logger.debug("Disconnected IDE : "
- + ideClientSocketArray.size());
+ String msg = in.readUTF();
+ Logger.debug(msg);
+ lastCommunicationIdeSocket = clientSocket;
+ parsingReceiveMessage(msg);
+ } catch (IOException e) {
+ Logger.debug("Disconnected IDE : "
+ + ideClientSocketArray.size());
+ try {
clientSocket.close();
- ideClientSocketArray.remove(clientSocket);
- break;
+ } catch (IOException e1) {
+ Logger.exception(e1);
}
- } catch (IOException e) {
+ ideClientSocketArray.remove(clientSocket);
Logger.exception(e);
break;
}