fix launching multiple instances of status desktop including on windows systems (#15533)

fixes #15493
This commit is contained in:
Godfrain Jacques 2024-07-12 08:15:03 -07:00 committed by GitHub
parent 38d155f590
commit 5db513980f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,12 +2,12 @@ import net
# Util function to test if a port is busy
proc isPortBusy*(port: Port): bool =
var sock: Socket
result = false
let socket = newSocket()
defer: socket.close()
try:
sock = newSocket()
sock.setSockOpt(OptReuseAddr, true)
sock.bindAddr(port)
sock.close()
return false
socket.connect("localhost", port)
result = true
except OSError:
return true
result = false