mirror of
https://github.com/Second-Hand-Friends/kleinanzeigen-bot.git
synced 2026-03-12 02:31:45 +01:00
19 lines
538 B
Python
19 lines
538 B
Python
# SPDX-FileCopyrightText: © Sebastian Thomschke and contributors
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
# SPDX-ArtifactOfProjectHomePage: https://github.com/Second-Hand-Friends/kleinanzeigen-bot/
|
|
import socket
|
|
|
|
|
|
def is_port_open(host:str, port:int) -> bool:
|
|
s:socket.socket | None = None
|
|
try:
|
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
s.settimeout(1)
|
|
s.connect((host, port))
|
|
return True
|
|
except Exception:
|
|
return False
|
|
finally:
|
|
if s:
|
|
s.close()
|