监听唤醒端口允许漂移,防止唤醒端口被其他程序占用时无法实现唤醒
This commit is contained in:
parent
2caa383f06
commit
0b19a75d7b
3
.gitignore
vendored
3
.gitignore
vendored
@ -35,4 +35,5 @@ build/
|
|||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
### Mac OS ###
|
### Mac OS ###
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
/.idea/encodings.xml
|
||||||
|
|||||||
@ -5,6 +5,8 @@ import cn.hutool.http.HttpResponse;
|
|||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.ServerSocket;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
|
||||||
@ -25,4 +27,15 @@ public class CustomUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int _findIdlePort(int port) {
|
||||||
|
for(int i=port; i<65535; i++){
|
||||||
|
try(ServerSocket ignored = new ServerSocket(i)){
|
||||||
|
ignored.close();
|
||||||
|
return i;
|
||||||
|
}catch (IOException ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user