Skip to content

Commit d07c76f

Browse files
committed
Revert "fix(openocd): fixed the port handler for verification for other processes"
This reverts commit a926bd6.
1 parent a926bd6 commit d07c76f

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/PortChecker.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,16 @@ private PortChecker()
2626

2727
public static boolean isPortAvailable(int port)
2828
{
29-
try (Socket socket = new Socket("127.0.0.1", port)) { //$NON-NLS-1$
30-
// If connection is successful, port is in use
31-
Logger.log("Port: " + port + " is not available (in use)"); //$NON-NLS-1$//$NON-NLS-2$
32-
return false;
33-
} catch (IOException e) {
34-
// If connection fails, port is likely available
35-
Logger.log("Port: " + port + " is available"); //$NON-NLS-1$ //$NON-NLS-2$
36-
return true;
37-
}
29+
try (ServerSocket serverSocket = new ServerSocket(port))
30+
{
31+
serverSocket.setReuseAddress(true);
32+
return true;
33+
}
34+
catch (Exception e)
35+
{
36+
Logger.log("Port: " + port + " is not available"); //$NON-NLS-1$ //$NON-NLS-2$
37+
return false;
38+
}
3839
}
3940

4041
/**

0 commit comments

Comments
 (0)