console start-up is now 0.9 second faster

This commit is contained in:
rusefi 2020-05-21 00:51:36 -04:00
parent 9905e8d38e
commit 7433127549
1 changed files with 4 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package com.rusefi.ui.util;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
@ -12,10 +13,12 @@ import java.net.Socket;
*/
public class JustOneInstance {
private static final int PORT = 29212;
private static final int LOCAL_CONNECTION_TIMEOUT_MS = 100;
public static boolean isAlreadyRunning() {
try {
Socket clientSocket = new Socket("localhost", PORT);
Socket clientSocket = new Socket();
clientSocket.connect(new InetSocketAddress("localhost", PORT), LOCAL_CONNECTION_TIMEOUT_MS);
System.out.println("*** Already running!");
return true;
} catch (IOException e) {