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
1 changed files with 7 additions and 7 deletions

View File

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