import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
-import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
}
try {
- ServerSocket so = new ServerSocket(Integer.parseInt(StrPortNo) + 1);
- } catch (Exception e) {
+ Socket so = new Socket("localhost", Integer.parseInt(StrPortNo) +1 );
MessageBox alert = new MessageBox(shell, SWT.OK);
- alert.setMessage("Can not start the target: " + property.getName() +"\nVirtual target with the same name is running now!"
- + "\nIf not, delete port info file: " + PortPath);
+ alert.setMessage("Can not start the target: " + property.getName() +"\nVirtual target with the same name is running now!");
alert.open();
return;
+ } catch (UnknownHostException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // means portNo not in use
+ e.printStackTrace();
}
}
package org.tizen.emulator.manager.tool;
import java.io.IOException;
-import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.UnknownHostException;
public class PortHelper {
- ServerSocket so;
+ Socket so;
public int getPortNo()
{
int port;
for(port=26100;port < 26200; port += 10) {
try {
- so = new ServerSocket(port+1);
- return port;
+ so = new Socket("localhost", port+1);
+ } catch (UnknownHostException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
} catch (IOException e) {
- continue;
- }
-
+ // TODO Auto-generated catch block
+ return port;
+ }
}
return -1;
}