Initial commit for tst

This commit is contained in:
2026-02-08 14:33:45 +08:00
parent bb01265fb1
commit 505cfe929d
27 changed files with 5855 additions and 0 deletions

31
AIMonitor/test.py Normal file
View File

@@ -0,0 +1,31 @@
import socket
def check_port(host='127.0.0.1', port=8765):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(2)
try:
result = sock.connect_ex((host, port))
if result == 0:
print(f"✅ 端口 {port}{host} 已开放")
return True
else:
print(f"❌ 端口 {port}{host} 未开放 (错误码: {result})")
return False
except Exception as e:
print(f"❌ 检查端口失败: {e}")
return False
finally:
sock.close()
if __name__ == "__main__":
# 测试不同地址
print("测试本地连接:")
check_port('127.0.0.1', 8765)
print("\n测试回环地址:")
check_port('localhost', 8765)
print("\n测试所有网络接口:")
check_port('0.0.0.0', 8765)