📜  socket python 如何检查服务器是否存活 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:51.921000             🧑  作者: Mango

代码示例1
import socket
s = socket.socket(
    socket.AF_INET, socket.SOCK_STREAM)
try:
    s.connect(("localhost", 10000))
except socket.error as e:
    print e
OUTPUT
[Errno 111] Connection refused