您好,登錄后才能下訂單哦!
#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()
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。