>>>")whileTrue:conn,addr=server.accept()print("接受了一" />
发布时间:2019-09-05 07:06:10编辑:auto阅读(2506)
#Author Kang
import os
import subprocess
import socket
server = socket.socket()
server.bind(('localhost',9999))
server.listen()
print("等待客户端连接:>>>>")
while True:
conn,addr = server.accept()
print("接受了一个新的链接!!")
while True:
data = conn.recv(10240)
cmd = subprocess.getstatusoutput(data.decode())
print("执行命令:>>",cmd)
if len(cmd[1]) != 0:
conn.send(cmd[1].encode("utf-8"))
elif cmd[0] == 0 and len(cmd[1]) == 0:
res = '命令执行成功,但没有返回值'
conn.send(res.encode("utf-8"))
if len(data) == 0:
break
server.close()
#Author Kang
import socket
client = socket.socket()
client.connect(('localhost',9999))
while True:
msg = input("请输入你要传递的信息:>>>>>")
if len(msg) == 0:
continue
client.send(msg.encode("utf-8"))
data = client.recv(10240).decode()
print(data)
client.close()
上一篇: LINUX DNS解析的3种修改方法
下一篇: python 异步程序 dramatiq
54154
40910
35431
31060
25953
25686
24137
19683
15740
15206
1968°
1817°
1901°
1997°
1982°
2162°
2121°
1937°
2014°
1999°