- Added automatic port check and reminder for beginners
This commit is contained in:
Toby Chui
2025-01-18 15:19:55 +08:00
parent bfd64a885e
commit eeb438eb18
2 changed files with 32 additions and 4 deletions

View File

@@ -157,3 +157,13 @@ func resolveIpFromDomain(targetIpOrDomain string) string {
return targetIpAddrString
}
// Check if the given port is already used by another process
func CheckIfPortOccupied(portNumber int) bool {
listener, err := net.Listen("tcp", ":"+strconv.Itoa(portNumber))
if err != nil {
return true
}
listener.Close()
return false
}