gpt4 book ai didi

python - 使用 Python 检查来自 IP 地址的网络连接

转载 作者:行者123 更新时间:2023-11-28 21:59:20 26 4
gpt4 key购买 nike

如何使用 python 检查来自特定 ip 地址的连接是否仍然存在。

最佳答案

ping IP地址

import os
#192.168.1.10 is the ip address
ret = os.system("ping -o -c 3 -W 3000 192.168.1.10")
if ret != 0:
print "pc still alive"

好吧,在任何情况下,您确实想检查您尝试连接的 PC 上传入连接的可用性,您需要制作一个程序来接收已经不可能的连接。

关于python - 使用 Python 检查来自 IP 地址的网络连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16808721/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com