File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed
bundles/com.espressif.idf.core/src/com/espressif/idf/core/util Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff 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 /**
You can’t perform that action at this time.
0 commit comments