[Title]revert socket
authormunkyu.im <munkyu.im@samsung.com>
Thu, 15 Mar 2012 21:27:46 +0000 (06:27 +0900)
committermunkyu.im <munkyu.im@samsung.com>
Thu, 15 Mar 2012 21:27:46 +0000 (06:27 +0900)
[Type]
[Module]
[Priority]
[CQ#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

src/org/tizen/emulator/manager/tool/Launcher.java
src/org/tizen/emulator/manager/tool/PortHelper.java

index 6a7c38b..423ad06 100644 (file)
@@ -5,7 +5,8 @@ import java.io.File;
 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;
 
@@ -45,13 +46,17 @@ public class Launcher {
                        }
 
                        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();
                        }
                }
 
index 36b4ffb..9eb5e5c 100644 (file)
@@ -1,21 +1,24 @@
 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;
        }