MAC OS X telnet 客户端

MAC 下运行的 telnet 客户端,需要安装 python3 的环境。
`#!/usr/local/bin/python3
import socket
import sys
import re

if name == ‘main‘:
if len(sys.argv) != 3:
print("Usage: telnet [remote_ip | FQDN] [remote_port]")
exit()
if re.match(r"\d{1,5}",sys.argv[2]) is None:
print("remote port must be number")
exit()
hostname = sys.argv[1]
remote_port = int(sys.argv[2])
telnet_client = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
try:
telnet_client.connect((hostname,remote_port))
print(hostname+":"+str(remote_port)+" is open\n")
exit()
except Exception:
print(hostname+":"+str(remote_port)+" is closed\n")
exit()`

MAC OS X telnet 客户端

上一篇:NET CORE在Linux下部署并且用Nginx 做负载均衡(主要说明CentOS)


下一篇:Http的长连接和短连接