我在Python中使用子进程和套接字模块时遇到了困难。发生的事情是,我将命令发送到客户端,但它不会返回任何内容。直到,我发送另一个命令,并获得前一个命令的输出。我尝试了所有的缓冲区大小,但都没有效果
服务器:
while True:
shell = input(">> ")
conn.send(shell.encode())
data = conn.recv(1600)
print(data.decode())
客户端:
while True:
data = sock.recv(1600)
if not data: break
data = data.decode()
commd = subprocess.Popen(data, stdout=subprocess.PIPE, shell=True)
out, err = commd.communicate()
sock.send(out)
print("Exiting because no data")
目前没有回答
相关问题 更多 >
编程相关推荐