Skip to content

Commit

Permalink
Fix issue with invalid checking used port for PIO Home server
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankravets committed Nov 28, 2019
1 parent f9cae60 commit 5c388d4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions platformio/commands/home/command.py
Expand Up @@ -88,12 +88,13 @@ def cli(port, host, no_open, shutdown_timeout):
return

# if already started
already_started = False
socket.setdefaulttimeout(1)
already_started = True
try:
socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect((host, port))
already_started = True
except: # pylint: disable=bare-except
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((host, port))
s.close()
already_started = False
except (OSError, socket.error):
pass

home_url = "http://%s:%d" % (host, port)
Expand Down

0 comments on commit 5c388d4

Please sign in to comment.